Extensible WooCommerce Blocks
WooCommerce provides powerful extensibility mechanisms for customizing Cart, Checkout, and Product Collection blocks without modifying core code. This guide covers filters, Slot Fills, inner blocks, and integration points.Overview
Extensible blocks support three primary customization approaches:- Filters: Modify data and rendering output (prices, labels, CSS classes)
- Slot Fills: Inject custom components into predefined locations
- Inner Blocks: Add custom nested blocks to extensible parent blocks
Filter Registry
The Filter Registry allows you to register callbacks that modify block behavior and appearance.Registering Filters
UseregisterCheckoutFilters to register multiple filters at once:
The first parameter (
my-extension) is your unique namespace. Use your plugin slug to avoid conflicts.Available Cart & Checkout Filters
Cart Line Items
Checkout Actions
Totals and Coupons
Context-Aware Filtering
Filters receive context information to enable conditional logic:The
args parameter contains context, cartItem, and extensions data. Always check context to ensure filters apply in the right location.Slot Fills
Slot Fills allow you to inject custom React components into predefined locations in Cart and Checkout blocks.Using Slot Fills
Available Slots
ExperimentalOrderMeta
Renders below the order summary, above “Proceed to Checkout”:cart: Cart data in camelCaseextensions: Custom data from ExtendSchemacontext: Block name (woocommerce/cartorwoocommerce/checkout)
ExperimentalOrderShippingPackages
Renders inside shipping options:collapsible: Whether panels are collapsiblecollapse: Whether panels start collapsedshowItems: Whether to show package contentsnoResultsMessage: React element for no resultsrenderOption: Function to render shipping ratescart,extensions,context,components
ExperimentalOrderLocalPickupPackages
Renders in Checkout Pickup Options (Checkout only):renderPickupLocation: Function to render pickup addresscart,extensions,components
ExperimentalDiscountsMeta
Renders below the coupon code input:cart,extensions,context
Inner Blocks
Add custom blocks as children of Cart and Checkout blocks.Creating an Inner Block
Registering Inner Blocks
Register your inner block type with the filter:Product Collection Extensibility
Product Collection blocks support custom collections and filters.Registering Custom Collections
Custom Collection with Query
Custom Inner Blocks
Preview State Management
DOM Events
WooCommerce blocks emit custom DOM events for inter-block communication.Cart & Checkout Events
Product Collection Events
Integration Interface
UseIntegrationInterface to properly register scripts and data:
Troubleshooting
Filter Not Working
If logged in as administrator, you’ll see error messages in the UI and console:Slot Fill Not Rendering
Ensure correct scope:Script Not Loading
Verify asset file is generated:Next Steps
Tutorials
Build complete examples step-by-step
Store API Extension
Add custom data to cart and checkout endpoints
Additional Checkout Fields
Add custom fields to checkout forms
Payment Method Integration
Create custom payment method blocks