Adding data to the block Cart and Checkout with the Store API

Classic template hooks don't run in the block Cart and Checkout. Add your data through the Store API instead.

Hamid Aarab Senior WordPress and WooCommerce Backend Developer
Published
Reading time
1 min read

Hamid Aarab February 24, 2026 1 min read

تصویر پیکسلی سبد خرید متصل به یک API
Contents (3)

WooCommerce’s block Cart and Checkout run on the Store API, not on PHP templates. Hooks such as woocommerce_review_order_before_payment don’t fire on these pages.

Register extra data on the cart endpoint

woocommerce_store_api_register_endpoint_data( [
    'endpoint'        => \Automattic\WooCommerce\StoreApi\Schemas\V1\CartSchema::IDENTIFIER,
    'namespace'       => 'hamidarab-delivery',
    'data_callback'   => static fn () => [ 'window' => get_delivery_window() ],
    'schema_callback' => static fn () => [
        'window' => [ 'type' => 'string', 'readonly' => true ],
    ],
    'schema_type'     => ARRAY_A,
] );

The data appears in the Store API response under extensions.hamidarab-delivery and is available on the JavaScript side.

Show it in the UI

Use Slot/Fill or an inner Checkout block to render it; jQuery DOM manipulation on these pages is fragile.

Before migrating to the block Checkout, list every existing checkout customisation so nothing is lost.

What to test

  • Inspect the /wp-json/wc/store/v1/cart response directly.
  • Test guest and logged-in customers separately.
  • Check behaviour behind page cache and CDN; the Store API must never be cached.

$ ./request_review

Facing the same problem in your own store?

Senior WordPress and WooCommerce backend engineering for complex production problems.

Request a Technical Assessment

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *