Hooks & Filters
The ecosystem exposes over 150 hooks and filters for extending the plugin, theme, and modules — roughly 90 in the plugin (wpec_*) and 65 in the theme (flavor_*). They follow standard WordPress add_action() / add_filter() semantics, so anything you already know about the WordPress plugin API applies here.
| Surface | Actions | Filters | Total |
|---|---|---|---|
Plugin (wpec_*) | ~63 | ~30 | ~93 |
Theme (flavor_*) | ~50 | ~16 | ~66 |
How Hooks Work
Just like WordPress core, you attach callbacks to actions and filters:
// Action — do something when an event occurs
add_action('wpec_order_created', function ($order, $checkout) {
my_crm_sync($order);
}, 10, 2);
// Filter — modify data before it's used
add_filter('wpec_product_price', function ($price, $product) {
return $price * 0.9; // 10% discount
}, 10, 2);
Naming Conventions
| Prefix | Source | Example |
|---|---|---|
wpec_ | WP eCommerce Core Plugin | wpec_order_created |
flavor_ | Flavor Starter Theme | flavor_cart_totals |
Plugin Hooks (wpec_*)
~90 hooks covering:
- Lifecycle — initialization, service registration, activation/deactivation
- Products & Variants — before/after save, delete, query, API response, variant save/delete (with a veto point)
- Shop / Search — sort options, products per page, search results, category response
- Cart — item added/updated/removed, cart cleared, price modification, calculated totals
- Checkout & Orders — order creation, status/payment/fulfillment changes, order number prefix, payment/shipping method filtering, order meta
- Customers — created/updated/deleted (drive CRM sync)
- Payments — gateway registration, payment processed/completed/failed, refunds, gateway logging
- Shipping — cost modification, method filtering, tracking URLs
- Inventory / WMS & Warehouses — stock changes, low-stock alerts, warehouse create/update/delete/activate
- Purchasing — purchase orders sent, goods received, supplier-price changes
- Invoicing — invoice issued
- ERP integration listeners — product-cost recompute, ERP-user removal, inventory backfill tuning
- HR — leave requested/approved/rejected
- Reviews — review created/approved
- Marketplace — order created/updated/accepted/rejected/ready
- Email — subject, content, recipients, headers, HTML, template data
- Licensing — feature-gate override (filter) + a read-only gate-check observability action
See Plugin Hooks Reference for the complete list with parameters.
Theme Hooks (flavor_*)
~65 hooks covering:
- Layout — header (before/start/end/after), content wrapper (before/after), footer (before/start/widgets/social/end/after)
- eCommerce Pages — shop, single product, categories, cart, checkout, order received, my account
- Lifecycle — initialization, service registration, translation registration, module registration (Module System 2.0)
- Page Builder — dynamic-tag registration, supported post types
- Module hooks — Stock Alerts, Request Quote, PDF Invoices, Points & Rewards, Newsletter, Abandoned Cart, Contact Form, Product Bundles, Header/Footer Builder
- Filters — initial React state, cart totals, popular search terms, placeholder images, builder/editor post types, content width, smart asset rules, marketing consent, AI image host allowlist, and more
See Theme Hooks Reference for the complete list.
The Flavor AI agent surface (Abilities exposed over the flavor-mcp MCP server) is not built on do_action/apply_filters. Abilities are registered by extending an ability base class and calling wp_register_ability() (WordPress Abilities API). Only the theme's AI content helper exposes a hook — the flavor_ai_image_download_hosts filter (host allowlist). Everything else in the AI layer is a class-extension model documented separately, not on this page.
Where to Place Hook Code
- Custom plugin (recommended): Create a simple plugin in
wp-content/plugins/my-customizations/ - Child theme functions.php (quick testing): Add to a child theme's
functions.php - mu-plugins (must-use): Place in
wp-content/mu-plugins/for always-active code
<?php
/**
* Plugin Name: My Store Customizations
* Description: Custom hooks and filters for my store
*/
// Modify cart totals
add_filter('flavor_cart_totals', function($totals, $cart) {
$totals['custom_fee'] = 5.00;
$totals['total'] += 5.00;
return $totals;
}, 10, 2);
// React to stock changes
add_action('wpec_stock_changed', function($productId, $variantId, $warehouseId, $movement) {
external_inventory_sync($productId, $movement);
}, 10, 4);
Common Patterns
Price Modification
// B2B pricing: 20% discount for wholesale customers
add_filter('wpec_product_price', function($price, $product) {
if (current_user_can('wholesale_customer')) {
return $price * 0.80;
}
return $price;
}, 10, 2);
Custom Order Metadata
add_filter('wpec_checkout_order_meta', function($meta, $checkout) {
if (isset($_COOKIE['referral_code'])) {
$meta['referral_code'] = sanitize_text_field($_COOKIE['referral_code']);
}
return $meta;
}, 10, 2);
API Response Enhancement
add_filter('wpec_api_product_response', function($response, $product) {
$response['estimated_delivery'] = calculate_delivery_date($product->getId());
return $response;
}, 10, 2);
React State Injection
add_filter('flavor_initial_state', function($state) {
$state['myPlugin'] = [
'apiUrl' => rest_url('my-plugin/v1/'),
'settings' => get_my_plugin_settings(),
];
return $state;
});
Registering Translatable Strings
The theme ships its own translation registry (independent of WordPress i18n). To add strings from an extension, hook the flavor_register_translations action and register through Flavor_Translation_Registry, then read them with flavor_t() / flavor_te():
add_action('flavor_register_translations', function() {
Flavor_Translation_Registry::registerMany([
'my_plugin.welcome' => 'Welcome to our store',
'my_plugin.cta' => 'Shop now',
]);
});
// Read anywhere after strings are registered:
echo flavor_t('my_plugin.welcome'); // returns the (possibly translated) string
flavor_te('my_plugin.cta'); // echoes it, HTML-escaped
flavor_register_string()Use Flavor_Translation_Registry::register($key, $default) (single) or ::registerMany([...]) (batch) — there is no flavor_register_string() function. See the Theme Hooks Reference for details.
Versioning
- New hooks are added in minor versions (x.Y.0)
- Existing hooks are never removed without a major version bump (X.0.0)
- Hook parameter changes are documented in the changelog
Coverage Summary
| Area | Actions | Filters | Status |
|---|---|---|---|
| Plugin Lifecycle | 5 | 0 | Stable |
| Products & Variants | 8 | 8 | Stable |
| Shop / Search / Category | 0 | 4 | Stable |
| Cart | 4 | 2 | Stable |
| Checkout & Orders | 9 | 4 | Stable |
| Customers | 4 | 0 | Stable |
| Payments | 6 | 0 | Stable |
| Shipping | 0 | 3 | Stable |
| Inventory / WMS | 2 | 1 | Stable |
| Warehouses | 6 | 0 | Stable |
| Purchasing | 3 | 1 | Stable |
| Invoicing | 1 | 0 | Stable |
| ERP Integration | 2 | 0 | Stable |
| HR | 3 | 0 | Stable |
| Reviews | 2 | 0 | Stable |
| Marketplace | 5 | 0 | Stable |
| 2 | 6 | Stable | |
| Licensing | 1 | 1 | Stable |
| Theme Layout | 13 | 0 | Stable |
| Theme eCommerce Pages | 18 | 0 | Stable |
| Theme Lifecycle | 5 | 0 | Stable |
| Theme Page Builder | 1 | 2 | Stable |
| Theme Modules | 13 | 5 | Stable |
| Theme Core Filters | 0 | 9 | Stable |