Changes to block integration hook timing in WooCommerce 11.4

Starting in WooCommerce 11.4, we are optimizing block initialization, which will be completed in 11.5. WordPress registers these blocks on init. Their integration hooks now fire the first time the block renders on the server, so a request that never renders the block may never fire its hook.

What’s changed

Technically, those PRs aim at two distinct areas:

  • Setting clearer boundaries for WooCommerce blocks integration.
  • Introducing lazy-loading for WooCommerce blocks.

The lazy-loading references to how the block classes are getting instantiated:

  • Previously, all blocks were registered and instantiated eagerly during init .
  • Now the blocks are split into two buckets: eagerly loaded and lazily loaded.

The lazily loaded blocks are registered during init (no life-cycle changes here), but instantiated only when they render on frontend. This has subtle implications to when blocks actions are getting executed:

  • woocommerce_blocks_{block_name}_block_registration: now fires during rendering, not during init .
Expand to see the full list of migrated blocks
  • woocommerce/cart-accepted-payment-methods-block
  • woocommerce/cart-cross-sells-block
  • woocommerce/cart-cross-sells-products-block
  • woocommerce/cart-express-payment-block
  • woocommerce/cart-items-block
  • woocommerce/cart-line-items-block
  • woocommerce/cart-order-summary-block
  • woocommerce/cart-order-summary-coupon-form-block
  • woocommerce/cart-order-summary-discount-block
  • woocommerce/cart-order-summary-fee-block
  • woocommerce/cart-order-summary-heading-block
  • woocommerce/cart-order-summary-shipping-block
  • woocommerce/cart-order-summary-subtotal-block
  • woocommerce/cart-order-summary-taxes-block
  • woocommerce/cart-order-summary-totals-block
  • woocommerce/cart-totals-block
  • woocommerce/empty-cart-block
  • woocommerce/filled-cart-block
  • woocommerce/proceed-to-checkout-block
  • woocommerce/checkout-actions-block
  • woocommerce/checkout-additional-information-block
  • woocommerce/checkout-billing-address-block
  • woocommerce/checkout-contact-information-block
  • woocommerce/checkout-fields-block
  • woocommerce/checkout-order-note-block
  • woocommerce/checkout-order-summary-block
  • woocommerce/checkout-order-summary-cart-items-block
  • woocommerce/checkout-order-summary-coupon-form-block
  • woocommerce/checkout-order-summary-discount-block
  • woocommerce/checkout-order-summary-fee-block
  • woocommerce/checkout-order-summary-shipping-block
  • woocommerce/checkout-order-summary-subtotal-block
  • woocommerce/checkout-order-summary-taxes-block
  • woocommerce/checkout-order-summary-totals-block
  • woocommerce/checkout-payment-block
  • woocommerce/checkout-pickup-options-block
  • woocommerce/checkout-shipping-address-block
  • woocommerce/checkout-shipping-method-block
  • woocommerce/checkout-shipping-methods-block
  • woocommerce/checkout-terms-block
  • woocommerce/checkout-totals-block
  • woocommerce/empty-mini-cart-contents-block
  • woocommerce/filled-mini-cart-contents-block
  • woocommerce/mini-cart-cart-button-block
  • woocommerce/mini-cart-checkout-button-block
  • woocommerce/mini-cart-footer-block
  • woocommerce/mini-cart-items-block
  • woocommerce/mini-cart-products-table-block
  • woocommerce/mini-cart-shopping-button-block
  • woocommerce/mini-cart-title-block
  • woocommerce/mini-cart-title-items-counter-block
  • woocommerce/mini-cart-title-label-block
  • woocommerce/order-confirmation-status
  • woocommerce/order-confirmation-summary
  • woocommerce/order-confirmation-totals
  • woocommerce/order-confirmation-totals-wrapper
  • woocommerce/order-confirmation-downloads
  • woocommerce/order-confirmation-billing-wrapper
  • woocommerce/order-confirmation-shipping-wrapper
  • woocommerce/order-confirmation-additional-information
  • woocommerce/order-confirmation-additional-fields
  • woocommerce/order-confirmation-billing-address
  • woocommerce/order-confirmation-shipping-address
  • woocommerce/order-confirmation-downloads-wrapper
  • woocommerce/order-confirmation-additional-fields-wrapper
  • woocommerce/add-to-cart-with-options
  • woocommerce/add-to-cart-with-options-quantity-selector
  • woocommerce/add-to-cart-with-options-variation-description
  • woocommerce/add-to-cart-with-options-variation-selector
  • woocommerce/add-to-cart-with-options-variation-selector-attribute
  • woocommerce/add-to-cart-with-options-variation-selector-attribute-name
  • woocommerce/add-to-cart-with-options-grouped-product-selector
  • woocommerce/add-to-cart-with-options-grouped-product-item
  • woocommerce/add-to-cart-with-options-grouped-product-item-selector
  • woocommerce/add-to-cart-with-options-grouped-product-item-label
  • woocommerce/product-price
  • woocommerce/product-title
  • woocommerce/product-sku
  • woocommerce/product-sale-badge
  • woocommerce/product-summary
  • woocommerce/product-average-rating
  • woocommerce/product-rating
  • woocommerce/product-rating-counter
  • woocommerce/product-rating-stars
  • woocommerce/product-description
  • woocommerce/product-specifications
  • woocommerce/product-gallery
  • woocommerce/product-gallery-thumbnails
  • woocommerce/product-gallery-large-image-next-previous
  • woocommerce/product-meta
  • woocommerce/product-image-gallery
  • woocommerce/product-image
  • woocommerce/product-stock-indicator

How can developers tell if they are affected?

Search your code for woocommerce_blocks_{block_name}_block_registration and check for hooks tied to the blocks below. If a callback does setup that needs to happen before rendering, move that setup to an earlier hook (e.g. init due to non-deterministic block initialization timing, which can be during init when block is initialized eagerly or during content rendering when block is initialized lazily).

Please note that woocommerce_blocks_mini-cart_block_registration, woocommerce_blocks_cart_block_registration and woocommerce_blocks_checkout_block_registration hooks (guide) are unaffected by the change.

How can store owners tell if they are affected?

If you have a theme using blocks, the changes can be tested on a staging store running WooCommerce 11.4: add an item from a product page, open Mini-Cart, and place a test order. Check the confirmation page and any affected Site Editor customizations. There should be no visible changes nor JavaScript errors related to the migrated blocks.


One response to “Changes to block integration hook timing in WooCommerce 11.4”

Leave a Reply

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