WooCommerce as a System

9

questions

How do you check in code whether HPOS is enabled?

AutomatticWooCommerceUtilitiesOrderUtil::custom_orders_table_usage_is_enabled().

How do you react to any order save?

The woocommerce_after_order_object_save hook — it fires no matter where the order was saved from: admin, REST, checkout, CLI.

What is a data store in WooCommerce?

A class responsible for saving and reading a specific object type. The CRUD object doesn't know where its data lives. That's why HPOS could be introduced without changing the public API: only the order data store changed.

What is sync mode?

During the transition WooCommerce writes orders to both storages. You can roll back, and old plugins that read wp_posts still get data. After the transition sync is turned off because it doubles every write.

What is wc_product_meta_lookup and why does it exist?

A denormalized table with a product's price, stock, SKU and rating. WooCommerce uses it for sorting and filters to avoid slow JOINs on wp_postmeta.

Where is a guest customer's cart stored?

In the woocommerce_sessions table. The cookie holds only the session key. For a logged-in user the cart is also saved in user meta so it can be restored on another device.

Why does WooCommerce have its own Action Scheduler queue?

WP-Cron depends on site visits and has no statuses or retries. Action Scheduler stores jobs in the database, runs them in batches and logs errors. Webhooks, analytics, some emails and migrations run on it.

Why is HPOS faster?

Orders get their own tables with the needed columns and indexes (status, date, customer, total). No thousands of wp_postmeta rows per order and no heavy JOINs. Order search and reports don't compete with posts and pages.

Why is wc_get_products() better than WP_Query?

It takes parameters in WooCommerce terms (price, stock_status, sku, visibility), builds the query itself and returns WC_Product objects. The code doesn't depend on how the data is laid out in tables.