Woo data stores

From OrcaQubits/agentic-commerce-skills-plugins · View interactive version

Woo data stores is an AI agent skill from the GitHub repository OrcaQubits/agentic-commerce-skills-plugins. Work with WooCommerce CRUD data stores — WC_Product, WC_Order, WC_Customer, WC_Coupon data objects, custom data stores, HPOS migration, and getters/setters. Use when creating or modifying WooCommerce data objects or implementing custom data stores.

How to use this skill

Skill file

WooCommerce CRUD & Data Stores

Before writing code

Fetch live docs:

  1. Web-search site:developer.woocommerce.com crud data stores for CRUD documentation
  2. Web-search site:github.com woocommerce woocommerce HPOS for HPOS architecture
  3. Fetch https://github.com/woocommerce/woocommerce/wiki for architecture decisions

CRUD Architecture

Data Objects

WooCommerce's core entities extend WC_Data:

WC_Data Base Class

All CRUD objects inherit from WC_Data:

Getters and Setters

Meta Data

Data Stores

What Data Stores Do

Data stores abstract the persistence layer. The CRUD object calls generic methods (read, create, update, delete) on its data store, which handles the actual SQL.

Built-In Data Stores

| Object | Data Store | Storage |

|--------|-----------|---------|

| Product | WC_Product_Data_Store_CPT | wp_posts + wp_postmeta |

| Order (legacy) | WC_Order_Data_Store_CPT | wp_posts + wp_postmeta |

| Order (HPOS) | Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableDataStore | wp_wc_orders + related tables |

| Customer | WC_Customer_Data_Store | wp_users + wp_usermeta |

| Coupon | WC_Coupon_Data_Store_CPT | wp_posts + wp_postmeta |

Custom Data Stores

You can swap data stores via the woocommerce_{object}_data_store filter:

  1. Implement WC_Object_Data_Store_Interface (or extend an existing data store)
  2. Implement methods: create(), read(), update(), delete(), read_meta(), update_meta(), delete_meta()
  3. Filter: add_filter( 'woocommerce_product_data_store', function() { return 'My_Custom_Store'; } )

HPOS (High-Performance Order Storage)

What Changed

HPOS moves order data from wp_posts/wp_postmeta to dedicated tables:

Why HPOS

Compatibility Modes

Sync-on-read is off by default

This is the failure mode to design against. WooCommerce disabled HPOS sync on read by default in the 10.7 release cycle. Code that writes order data straight into wp_postmeta and expects it to appear in HPOS now fails silently — no error, no warning, just data that is never read back.

The practical consequence: legacy order writes are not merely discouraged any more, they are broken. Auditing a plugin for direct wp_postmeta order writes is no longer a tidiness exercise, it is a correctness fix.

Confirm the current default and the exact release in the live docs — fetch https://developer.woocommerce.com/docs/features/orders/high-performance-order-storage/ — but write code as though sync is off regardless of version. It is the safe assumption in every direction.

Declaring HPOS Compatibility

add_action( 'before_woocommerce_init', function() {
    if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
        \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility(
            'custom_order_tables', __FILE__, true
        );
    }
});

HPOS-Compatible Code

Querying

wc_get_orders()

The proper way to query orders (HPOS-compatible):

wc_get_products()

Query products — delegates to WC_Product_Query:

Best Practices

Fetch the WooCommerce CRUD and HPOS documentation for exact method signatures, query parameters, and compatibility requirements before implementing.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.