Skip to main content

Hooks & Filters

The ecosystem provides 100+ hooks and filters for third-party extensibility across the plugin, theme, and modules.

How Hooks Work

Just like WordPress core, you can 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

PrefixSourceExample
wpec_WP eCommerce Core Pluginwpec_order_created
flavor_Flavor Starter Themeflavor_cart_totals

Plugin Hooks (wpec_*)

50+ hooks covering:

  • Lifecycle — initialization, service registration, activation/deactivation
  • Products — before/after save, delete, query, API response
  • Shop/Search — sort options, products per page, search results
  • Cart — item added/updated/removed, price modification, totals
  • Checkout & Orders — order creation, status changes, payment/fulfillment status, order number prefix
  • Payments — gateway registration, payment processed/completed/failed, refunds
  • Shipping — cost modification, method filtering, tracking URLs
  • Inventory/WMS — stock changes, low stock alerts
  • Purchasing — purchase orders sent, goods received
  • Invoicing — invoice issued
  • Marketplace — order created/updated/accepted/rejected/ready
  • Email — subject, content, recipients, headers, template data
  • Licensing — feature gate override

See Plugin Hooks Reference for the complete list.

Theme Hooks (flavor_*)

55+ hooks covering:

  • Layout — header (before/start/end/after), footer (before/start/widgets/social/end/after), content wrapper
  • eCommerce Pages — shop, single product, categories, cart, checkout, order received, my account
  • Lifecycle — initialization, service registration, translation registration
  • Module hooks — Stock Alerts, Request Quote, PDF Invoices, Points & Rewards, Newsletter, Abandoned Cart, Contact Form, Product Bundles
  • Filters — initial React state, cart totals, popular search terms, placeholder images, builder post types, content width, smart asset rules, marketing consent, and more

See Theme Hooks Reference for the complete list.

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 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;
});

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

AreaActionsFiltersStatus
Plugin Lifecycle50Stable
Products46Stable
Shop / Search04Stable
Cart42Stable
Checkout & Orders74Stable
Payments60Stable
Shipping03Stable
Inventory / WMS20Stable
Purchasing20Stable
Invoicing10Stable
Marketplace50Stable
Email26Stable
Licensing01Stable
Theme Layout140Stable
Theme eCommerce Pages120Stable
Theme Lifecycle40Stable
Theme Modules120Stable
Theme Filters013Stable