Monday, 10:05 AM
A client writes: "The price filter shows products that are out of stock." You open the product: stock 0, status "Out of stock". Everything is correct. But the filter doesn't read the product, it reads wc_product_meta_lookup. Nobody updated it, because the nightly import wrote stock straight into wp_postmeta.
As long as WooCommerce is "posts with meta fields" to you, a bug like this takes hours to find.
Goal
After the lesson you know where WooCommerce stores products, orders, the cart and background jobs, and from a symptom you immediately know which table to check.
Key concepts
WC()— the plugin's main object:WC()->cart,WC()->session,WC()->customer,WC()->mailer()- Products — posts of type
productandproduct_variation+ thewc_product_meta_lookuptable for fast filters - Orders — HPOS tables
wc_orders,wc_order_addresses,wc_order_operational_data,wc_orders_meta - A guest's cart — in
woocommerce_sessions, not in a cookie - Background jobs — Action Scheduler tables (
actionscheduler_actions,actionscheduler_logs) - Attributes —
pa_*taxonomies, categories —product_cat, visibility — theproduct_visibilitytaxonomy
Diagram
erDiagram
wp_posts ||--o{ wp_postmeta : "product / product_variation"
wp_posts ||--|| wc_product_meta_lookup : "price, stock, SKU"
wc_orders ||--o{ wc_order_addresses : "billing / shipping"
wc_orders ||--|| wc_order_operational_data : "internal data"
wc_orders ||--o{ wc_orders_meta : "order meta"
wc_orders ||--o{ woocommerce_order_items : "line items"
woocommerce_order_items ||--o{ woocommerce_order_itemmeta : "qty, total, product_id"
woocommerce_sessions }o--|| wc_orders : "cart → checkout"
Code
List the WooCommerce tables in your database:
SHOW TABLES LIKE '%wc\_%';
SHOW TABLES LIKE '%woocommerce\_%';
SHOW TABLES LIKE '%actionscheduler\_%';
Common mistakes
| Symptom | Cause | Fix |
|---|---|---|
| The price filter is very slow | meta_query on _price in wp_postmeta | Filter via wc_get_products() / the lookup table |
Order "not found" via get_post() | HPOS is on: orders are not in wp_posts | wc_get_order( $id ) |
| The database grows for no reason | Old sessions and Action Scheduler logs | Check session cleanup and log retention |
Weak and strong answer
Question: Where does WooCommerce store orders?
Weak answer. In
wp_postswith typeshop_order, and the data inwp_postmeta.
Strong answer. It depends on the setting. New sites since 8.2 use the HPOS tables (
wc_ordersand related). Older ones may usewp_postsor sync mode. That's why my code never touches the tables directly, onlywc_get_order()and CRUD.
Why the second is stronger: The candidate knows the current state, remembers both storages and draws a conclusion for the code.
Practice
Open the database of a test store. Find one order in wc_orders, its addresses in wc_order_addresses and its line items in woocommerce_order_items. Draw these relations by hand or in Mermaid. In the terminal below, try the wp wc commands to view the data.
Interview Questions
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.
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.
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.