Skip to main content

Getting Started with WooCommerce Blocks

WooCommerce Blocks provide a modern, block-based approach to building e-commerce experiences in WordPress. Built on the WordPress Gutenberg editor, WooCommerce Blocks enable you to create dynamic, customizable shopping experiences using React and TypeScript.

What are WooCommerce Blocks?

WooCommerce Blocks are reusable components that extend the WordPress Block Editor to provide e-commerce functionality. They leverage the WordPress Gutenberg architecture to deliver:
  • Modern React Components: Built with TypeScript and React for type safety and maintainability
  • Server-Side Rendering: PHP integration for optimal performance and SEO
  • Store API Integration: RESTful API for cart, checkout, and product data
  • Extensibility: Hooks, filters, and Slot Fills for customization

Block Architecture

WooCommerce blocks follow the WordPress Block API specification:

Types of WooCommerce Blocks

Product Blocks

Display and interact with products:
  • Product Collection: Display filterable product collections with customizable queries
  • Product Gallery: Showcase product images with thumbnails and large image views
  • Product Filters: Enable filtering by attributes, price, ratings, and taxonomy
  • Product Reviews: Display customer reviews with pagination and filtering
  • Single Product: Render individual product details and metadata

Cart & Checkout Blocks

Handle the purchase flow:
  • Cart Block: Modern cart experience with line items, totals, and coupon support
  • Checkout Block: Multi-step checkout with address fields, payment methods, and order summary
  • Mini Cart: Slide-out cart accessible from anywhere on the site
Cart and Checkout blocks are highly extensible with Slot Fills, filters, and custom inner blocks. See the Extensible Blocks guide for details.

Product Editor Blocks

Build custom product editing interfaces:
  • Product Fields: Input controls for name, price, description, inventory
  • Generic Blocks: Reusable form components (sections, tabs, subsections)
  • Custom Blocks: Extension points for plugin-specific product data
Example product editor block structure:

Gutenberg Integration

WooCommerce blocks integrate seamlessly with WordPress Gutenberg:

Block Registration

Blocks are registered using the WordPress Block API:

Block Context

Blocks can share data through context:

Inner Blocks

Create nested block structures:

Development Environment Setup

Build System

WooCommerce blocks use @wordpress/scripts for build configuration:

Dependency Extraction

The WooCommerceDependencyExtractionWebpackPlugin automatically:
  • Externalizes WordPress and WooCommerce dependencies
  • Generates .asset.php files with dependency lists and versions
  • Maps imports to global variables (e.g., @woocommerce/blocks-checkout → window.wc.wcBlocksCheckout)

Registering Scripts

Enqueue blocks using the generated asset file:

Available Components

WooCommerce provides reusable React components:
View all available components in the WooCommerce Storybook under “WooCommerce Blocks → External components”.

Data Stores

Access WooCommerce data using WordPress data stores:
All WooCommerce Interactivity API stores are private (lock: true). Do not rely on internal store structure as it may change without notice. Use exported selectors and actions only.

Next Steps

Extensible Blocks

Learn how to extend Cart, Checkout, and Product Collection blocks with filters and Slot Fills

Tutorials

Follow step-by-step guides to build custom WooCommerce blocks

Store API

Extend the REST API to add custom data to cart and checkout

Block Reference

Explore detailed API documentation for filters, hooks, and components

Resources