plugins/woocommerce/client/blocks/packages/internal/entities/README.md
This module contains the entity helpers for WooCommerce. Entities provide a standardized way to interact with WordPress data stores and enable consistent data access patterns across the admin interface.
The pure entity helpers in this directory are bundled into their consumers and can be tree-shaken. Registration lives separately in ../entity-registration and builds as a dedicated script that loads consistently on every admin screen.
For backward compatibility, the registration script continues to expose the runtime helpers on wc.wcEntities. That global API is deprecated as of WooCommerce 11.1.0 and emits a warning when a helper is called.
The product entity provides access to WooCommerce product data through WordPress's core data store. It includes:
Entities are automatically registered on every admin page through the wc-entities script. The script performs registration as a side effect and temporarily retains the deprecated wc.wcEntities global for backward compatibility.
The manual registration functions remain exported temporarily for compatibility:
import { registerProductEntity } from './entities/register-entities';
registerProductEntity();
These functions are deprecated as of WooCommerce 11.1.0 and emit a warning when called. Rely on the automatically loaded wc-entities script instead.
import { useProduct } from './entities/product';
function MyComponent() {
const { product, isLoading, error } = useProduct( 123 );
if ( isLoading ) return <div>Loading...</div>;
if ( error ) return <div>Error: { error.message }</div>;
return <div>{ product.name }</div>;
}