Woocommerce
-
WooCommerce – HPOS
🔧 What is HPOS in WooCommerce? Everything You Should Know 🧩 Introduction to HPOS HPOS (High-Performance Order Storage), formerly known as Custom Order Tables, is a new database architecture introduced by WooCommerce to dramatically improve performance, scalability, and reliability when managing orders. Traditionally, WooCommerce stored orders as shop_order post types in the wp_posts table, with associated metadata in wp_postmeta. While compatible with WordPress’s structure, this system has major performance bottlenecks — especially for large or high-volume stores. HPOS introduces dedicated database tables for orders, including: 📅 Timeline and Development Date Milestone Description Sept 2022 Public Beta in WooCommerce 7.1 First optional beta release, developers encouraged to test. Aug 2023 WooCommerce…
-
Finally here… required PHP version
I talked about it many times, I thought about it even more. However I was stupid enough not to talk about it to WordPress team. Well, somebody did. On March 2013 as far as I remember. And finally it is here… We can mark miminal required PHP version in plugins! And maybe in themes. It wasn’t very clear, but they mentioned themes As a next step, the WordPress core team is going look into showing users a notice that they cannot install a certain plugin or theme because their install does not meet the required criteria. I won’t test it, because I don’t have any themes in WordPress repository. [postad1]…
-
Get woocommerce random products
Sometimes people asks me how to get N random products from Woocommerce plugin. Well, I heard it isn’t obvious or easy. And still I don’t know why. It is more than easy! We just need to use `get_posts` function. Simplest function to get N random products (default value is three as you may see in the source code) would look like that: function my_wc_random_products( $count = 3 ) { $count = (int)$count; if ( $count < 1 ) { $count = 1; } return get_posts( [ 'posts_per_page' => $count, 'orderby' => 'rand', 'post_type' => 'product', ] ); } [postad1]
-
Add woocommerce category programmatically
As I promised in this article Assign woocommerce product categories programmatically, I will explain how to create woocommerce category programmatically. It is very easy, just use this code:
-
Assign woocommerce product categories programmatically
How to assign categories for your Woocommerce products programmatically? Well, it isn’t that hard. First of all, you must know the ID of your product. If you insert your product programmatically, it is easy, you got it. If not, you can see ID for many ways, for example in your edit screen (something like http://example.com/wp-admin/post.php?post=123&action=edit – 123 is your product ID). Let’s assume you’ve got your product ID in the $product_id variable. Now, you must decide if you want to assign product to existing category or create category by yourself? Well, if you already got category, you need your term ID. How to get it? Go to product categories list…
-
Insert new woocommerce product programmatically
How to insert brand new Woocommerce product programmatically? Sometimes you need your own product importer. You may read database, XML, JSON, CSV, XLS, XLSX, ODS, absolutely anything. Now you got all your products in memory or cache or your temporary file and what’s next? You need to add this product to Woocommerce… Well, the product is – like almost anything in WordPress – post type with specific taxonomy and meta data set. So, first things first, insert your new post: $post_id = wp_insert_post( array( 'post_title' => 'Great new product', 'post_content' => 'Here is content of the post, so this is our great new products description', 'post_status' => 'publish', 'post_type' =>…
-
Woocommerce product category fields
Yeah, we step into Woocommerce chambers. This is a huge, good plugin, widely recognizable, used on many many e-commerce sites. They got nice product category taxonomy and it works fine. But what if we need a few more fields? It’s not that hard as you may think so, because Woocommerce is well written plugin, we can hook into it without any trouble. We need four action hooks and three functions. I will use methods, because I prefer object oriented programming, but it’s pretty easy to convert it into functional programming. You may ask, why only three functions, when we want to use four hooks? Two hooks will be handled by…