# Building a custom WooCommerce extension

> When a specific business rule has no equivalent among existing WooCommerce extensions, the lasting fix isn’t to edit the plugin or theme files directly, but to write a dedicated extension that hooks into the extension points WooCommerce provides.

- Source canonique : [https://allaux.fr/en/wordpress-woocommerce/extension-sur-mesure](https://allaux.fr/en/wordpress-woocommerce/extension-sur-mesure)
- Langue : EN
- Dernière mise à jour : 2026-09-30

## Direct answer

> Create a folder in wp-content/plugins holding a PHP file with the Plugin Name header: that is where the business rule belongs, not in the theme’s functions.php, which would vanish with the next theme change. Hook into existing WooCommerce actions and filters with add_action or add_filter rather than overriding a template. Finally declare HPOS compatibility, or WooCommerce flags the plugin as incompatible.

## Why an extension rather than a direct edit

WooCommerce, like WordPress, runs on a system of actions and filters (add_action, add_filter) that let you step in at precise points in the lifecycle of an order, a product or the cart without touching the plugin’s own files. Hooks like woocommerce_checkout_process, woocommerce_order_status_changed or woocommerce_product_get_price cover most business needs, from conditional price calculations to validating custom fields at checkout.

Editing WooCommerce files directly, or a poorly structured child theme, falls into the same trap as a badly managed PrestaShop override: the change disappears at the next update, or worse, blocks the update itself. An extension packaged in its own plugin folder survives WooCommerce and WordPress updates as long as the hooks it uses stay stable.

When the need goes beyond what native hooks allow, I sometimes expose a custom REST API route to talk to an external system (ERP, till, management tool), rather than multiplying direct database calls from another tool.

## What triggers this kind of request

- A pricing or discount rule specific to your business, missing from marketplace extensions
- A sync between WooCommerce and an ERP, a till or a stock management tool
- Extra order or customer account fields with their own business logic
- Changes currently made in theme or plugin files, lost at every update
- A need for automation triggered by an order status change

## How I build an extension

1. **Scoping the need** — I clarify exactly what the extension needs to do, with which screens, which data and which interactions with the existing setup.
2. **Choosing the hooks** — I identify the right actions and filters to step in at the right moment without duplicating logic WooCommerce already handles.
3. **Isolated development** — The code is built in its own plugin, independent of the theme, to stay stable even if the theme changes later.
4. **Testing and documentation** — I test on a staging environment and leave short documentation on how it works and how to configure it.

## The code stays yours

> The extension is delivered as a standalone plugin, with no dependency on me to keep working. You can have it developed further by another developer if needed.

## Worth reading next

- **Custom development** — The framework I work within on a bespoke plugin. ([/services/developpement-sur-mesure](/services/developpement-sur-mesure))
- **Checking plugins before an update** — The version discipline a bespoke plugin imposes on you. ([/wordpress-woocommerce/mise-a-jour/verifier-extensions-avant-mise-a-jour](/wordpress-woocommerce/mise-a-jour/verifier-extensions-avant-mise-a-jour))
- **Plugin conflicts after an update** — The most common symptom of a stack of plugins piling up. ([/wordpress-woocommerce/problemes/conflit-extensions-apres-mise-a-jour](/wordpress-woocommerce/problemes/conflit-extensions-apres-mise-a-jour))
- **Creating a WordPress child theme** — When the customisation belongs to the theme rather than a plugin. ([/guides/creer-theme-enfant-wordpress](/guides/creer-theme-enfant-wordpress))
- **ChatGPT Ads extension for WooCommerce** — OpenAI pixel and Conversions API, compatible with HPOS, the block checkout and consent plugins: built and installed by me. ([/wordpress-woocommerce/extension-chatgpt-ads](/wordpress-woocommerce/extension-chatgpt-ads))

## Making a plugin operable by an AI assistant

- **WordPress and WooCommerce MCP** — Declare abilities for your plugins and expose them over MCP with limited rights. ([/wordpress-woocommerce/mcp](/wordpress-woocommerce/mcp))

## FAQ

### Will the extension survive WooCommerce updates?

Yes, by going through native hooks rather than editing files directly, the extension keeps working after an update. A check is still worthwhile at major WooCommerce version upgrades.

### How long does building an extension take?

From a few days for a simple feature to several weeks for a complex integration with an external system. I give a precise estimate once the need is scoped.

### Can I test it before it goes live?

Yes, development happens on a staging environment you can review and approve before anything goes to production.

### What happens if my needs change after delivery?

The extension can evolve afterwards. Since the code is isolated and documented, someone else can also pick it up if needed.

### Are you sure an existing extension really won’t do?

I always check first whether a marketplace solution fits: it’s often faster and cheaper than custom development. A dedicated extension is only proposed when nothing reliable already exists.
