Overview
WooCommerce uses a monorepo structure, meaning multiple related packages, plugins, and tools are maintained in a single repository. This approach enables code sharing, consistent versioning, and streamlined development workflows.Top-Level Structure
plugins/
Contains WordPress plugins related to WooCommerce:- woocommerce/ - The core WooCommerce plugin
- woocommerce-beta-tester/ - Beta testing tool
packages/
Shared code organized into reusable packages:packages/js/
Over 30 JavaScript/TypeScript packages for building WooCommerce interfaces:Packages prefixed with
internal- are not intended for public use and may change without notice.packages/php/
PHP packages for WooCommerce functionality:tools/
Development and release tools:WooCommerce Core Plugin Structure
The main WooCommerce plugin atplugins/woocommerce/ has a specific organization:
src/ - Modern PHP Code
Thesrc/ directory contains modern PHP code following PSR-4 autoloading standards:
Namespace Convention:
Automattic\WooCommerce\- Public API classes go directly in
src/ - Internal implementation goes in
src/Internal/
includes/ - Legacy Code
Theincludes/ directory contains legacy WordPress-style code:
client/ - React Admin
React-based admin interface:templates/
PHP template files for the storefront:Themes can override these templates by copying them to
your-theme/woocommerce/.tests/
Test suites for WooCommerce:Configuration Files
Root Configuration
- pnpm-workspace.yaml
- package.json
- tsconfig.base.json
Defines workspace packages:
Plugin Configuration
Each plugin has its own configuration:- package.json - npm scripts and dependencies
- composer.json - PHP dependencies
- .wp-env.json - WordPress environment config
- phpunit.xml - PHPUnit test configuration
Code Organization Principles
Modern vs Legacy
Modern Code (src/)
- PSR-4 autoloading
- Strict types
- Dependency injection
- Unit testable
- Type hints
Legacy Code (includes/)
- WordPress hooks
- Global functions
- Singletons
- Direct instantiation
- WordPress coding standards
When to Use Each
Usesrc/ for:
- New features and functionality
- Complex business logic
- Code requiring unit tests
- Internal services and utilities
includes/ for:
- Maintaining existing functionality
- WordPress-specific hooks
- Template functions
- Backward compatibility
Finding Your Way Around
Common Tasks
Where do I find...
Where do I find...
Product classes:
- Abstract:
includes/abstracts/abstract-wc-product.php - Simple:
includes/class-wc-product-simple.php - Variable:
includes/class-wc-product-variable.php
- Abstract:
includes/abstracts/abstract-wc-order.php - Order:
includes/class-wc-order.php - Order Item:
includes/class-wc-order-item.php
- V3 Controllers:
src/Admin/API/andincludes/rest-api/Controllers/Version3/ - V2 Controllers:
includes/rest-api/Controllers/Version2/
- Modern admin:
src/Admin/ - React UI:
client/admin/ - Legacy admin:
includes/admin/
- All templates:
templates/ - Template functions:
includes/wc-template-functions.php - Template hooks:
includes/wc-template-hooks.php
Package Dependencies
Packages can depend on each other. View dependencies inpackage.json:
workspace:* references packages within the monorepo.Building and Development
Building Specific Packages
Running Tests
Next Steps
Core Concepts
Learn about WooCommerce architecture
Monorepo Workflow
Master monorepo development
Modern vs Legacy
Understand code organization
Extension Development
Start building extensions