How to build extensions for WooCommerce
The short answer
You build a WooCommerce extension as a WordPress plugin: declare WooCommerce as a dependency, initialise after plugins load, then add features through public hooks and CRUD APIs. You can create the files by hand, but the official scaffold is faster and prepares testing and block support.
What you need
- A local WordPress and WooCommerce development site
- PHP and WordPress plugin development knowledge
- Node.js with npm
- Composer and Docker if using the official environment
The fast route
Get Aelia Foundation Classes for WooCommerce
Let Aelia Foundation Classes for WooCommerce do it
Reusable utilities for WooCommerce extension developers; choose it when Aelia add-ons need a shared foundation.
Sources
- developer.wordpress.org /plugins/plugin-basics/header-requirements/?utm_source=opena…
- developer.woocommerce.com /docs/extensions/getting-started-extensions/building-your-fi…
- woocommerce.github.io /code-reference/hooks/hooks?utm_source=openai
- developer.woocommerce.com /docs/features/orders/wc-get-orders/?utm_source=openai
- developer.woocommerce.com /docs/extensions/getting-started-extensions/how-to-design-a-…
Questions
- Do WooCommerce extensions need to be separate plugins?
- Yes, a WooCommerce extension is normally a WordPress plugin that depends on WooCommerce. Keeping it separate from a theme makes the feature portable and lets you update or disable it without changing the store’s design. Add the WooCommerce dependency in the plugin header where possible, then check that WooCommerce is loaded before registering extension code.
- Should I build a WooCommerce extension from scratch?
- You can build one from scratch, but the official scaffold is usually quicker for a new project. Manual development is fine for a small PHP-only feature when you already have a tested plugin structure; otherwise you must create the header, bootstrap, asset build, block integration and test setup yourself. The scaffold reduces that initial boilerplate.
- Which WooCommerce hooks should an extension use?
- Use the documented action or filter that matches the feature, rather than relying on a theme template or an internal class. The correct hook depends on whether you are changing products, cart calculations, checkout, orders, administration or Store API responses. Check the WooCommerce hook reference and confirm that the hook also applies to block-based screens when relevant.
- How do I make an extension compatible with HPOS?
- Use WooCommerce’s order CRUD and query APIs instead of direct SQL or WordPress post queries, then test with HPOS enabled and disabled. Declare HPOS compatibility only after testing the extension’s order creation, reading, updating and reporting behaviour. Direct access to legacy order tables is a common reason an extension is flagged as incompatible or stops seeing orders after migration.
- Do I need JavaScript to build a WooCommerce extension?
- Not always. A PHP-only extension can handle many server-side actions, settings and classic WooCommerce hooks, but JavaScript is often needed for modern admin interfaces, custom blocks or Cart and Checkout block integrations. The current WooCommerce development guidance uses PHP for lifecycle and server operations and JavaScript for parts of the interface and shopper experience.