The Developer-First
eCommerce Engine for WordPress
Omnify replaces sluggish wp_posts and wp_postmeta overhead with a purpose-built 27-table normalized SQL relational engine, atomic stock management, cryptographic link signing, and complete REST APIs.
System Pipeline & Data Flow
Omnify processes requests cleanly through decoupled application layers:
Pro Frontend Experience & Live Storefront Sandbox
Interactive PlaygroundExperience OmnifyWP's conversion-optimized Elessi-style 3-column single product page, real-time scarcity countdown cart, and frictionless multi-gateway checkout. Test responsive screen sizes, click variation swatches, and switch storefront brand accent colors live!
Quickstart & Installation
Omnify is distributed as a clean, self-contained WordPress plugin with zero external PHP dependencies.
# 1. Clone the repository
git clone https://github.com/omnifywp/omnifywp-ecommerce.git wp-content/plugins/omnify
# 2. Package into a distribution ZIP ready for installation
cd wp-content/plugins/omnify
node build.js
# 3. Output artifact: dist/omnifywp-ecommerce.zip
Runtime Requirements
| Component | Minimum | Recommended | Notes |
|---|---|---|---|
| PHP | 8.2.0+ | 8.3+ | Strict types, typed properties, match expressions, and union return types. |
| WordPress | 5.8+ | 6.4+ | Compatible with both Classic PHP themes and Full Site Editing (FSE). |
| MySQL | 5.7+ / MariaDB 10.3+ | MySQL 8.0+ | InnoDB engine with utf8mb4 collation support for emojis and global scripts. |
Architecture & Dependency Injection
Omnify utilizes an internal dependency container (Omnify_Container) exposed by the singleton Omnify_Plugin. Every repository, gateway, and service class is auto-wired with strict constructor injection.
use Omnify\eCommerce\Repositories\Omnify_Product_Repository;
use Omnify\eCommerce\Repositories\Omnify_Order_Repository;
// Fetch the plugin container anywhere in WordPress
$container = omnify()->container();
// Resolve auto-wired repositories
$product_repo = $container->get(Omnify_Product_Repository::class);
$order_repo = $container->get(Omnify_Order_Repository::class);
// Query products directly
$products = $product_repo->all([
'status' => 'published',
'per_page' => 20,
]);
Database Engine & 27 Relational Tables
Omnify isolates all commercial data from the WordPress post engine. Tables are prefixed with wp_omnify_* and indexed for high-concurrency throughput.
The 27 Core Database Tables
| Table | Primary Function | Indices & Keys |
|---|---|---|
wp_omnify_products | Master catalog records (download, simple, variable, bundle) | PRIMARY (id), UNIQUE KEY (slug), KEY (status, type) |
wp_omnify_product_variations | Format matrix (SKU, price swatches, attributes) | PRIMARY (id), KEY (product_id) |
wp_omnify_product_files | Physical files, versions, and attachments | PRIMARY (id), KEY (product_id), KEY (expires_at) |
wp_omnify_product_categories | Category terms & taxonomy linkages | PRIMARY (id), KEY (product_id), KEY (slug) |
wp_omnify_product_brands | Product brands & manufacturer terms | PRIMARY (id), KEY (product_id), KEY (slug) |
wp_omnify_product_tags | Faceted search and discovery tags | PRIMARY (id), KEY (product_id), KEY (slug) |
wp_omnify_orders | Orders, financial totals, currency, and tax tracking | PRIMARY (id), UNIQUE KEY (order_number), KEY (customer_id, status) |
wp_omnify_order_items | Snapshot of purchased items, prices, and quantities | PRIMARY (id), KEY (order_id), KEY (product_id) |
wp_omnify_order_notes | Staff internal comments & customer visibility updates | PRIMARY (id), KEY (order_id), KEY (customer_visible) |
wp_omnify_customers | Customer CRM profiles, addresses, and tax exemptions | PRIMARY (id), UNIQUE KEY (email), KEY (user_id), KEY (status) |
wp_omnify_customer_notes | CRM support notes attached to customer accounts | PRIMARY (id), KEY (customer_id), KEY (customer_visible) |
wp_omnify_customer_activity | Audit trail (logins, checkout started, address changes) | PRIMARY (id), KEY (customer_id), KEY (activity_type) |
wp_omnify_customer_access | Digital file entitlements & access permissions | PRIMARY (id), UNIQUE KEY (customer_id, product_id) |
wp_omnify_downloads | Cryptographic download stream transaction logs | PRIMARY (id), KEY (product_id), KEY (file_id), KEY (customer_id) |
wp_omnify_coupons | Promotional codes, percentage/fixed rules, limits | PRIMARY (id), UNIQUE KEY (code) |
wp_omnify_reviews | Product ratings, content, and approval states | PRIMARY (id), KEY (product_id), KEY (status) |
wp_omnify_abandoned_carts | Captured checkout inputs, recovery tokens, reminders | PRIMARY (id), UNIQUE KEY (token), KEY (email, status) |
wp_omnify_wishlists | Customer wishlist favorite associations | PRIMARY (id), UNIQUE KEY (user_id, product_id) |
wp_omnify_email_logs | Transactional email dispatch log & retry queue | PRIMARY (id), KEY (trigger_name), KEY (status) |
wp_omnify_metadata | Extensible key/value metadata for products, orders, customers | PRIMARY (id), KEY (object_type, object_id) |
wp_omnify_webhook_events | Inbound gateway webhook event ledger (dedupe & audit) | PRIMARY (id), KEY (gateway), KEY (event_id) |
wp_omnify_webhooks | Outbound webhook endpoints & topic subscriptions | PRIMARY (id), KEY (status) |
wp_omnify_webhook_delivery_logs | Outbound delivery attempts, HTTP status & latency | PRIMARY (id), KEY (webhook_id) |
wp_omnify_inventory_logs | Stock movement audit trail (reductions, restocks) | PRIMARY (id), KEY (product_id), KEY (variation_id) |
wp_omnify_stock_subscribers | Back-in-stock waitlist opt-ins per product/variation | PRIMARY (id), KEY (product_id) |
wp_omnify_admin_activities | Admin action audits & security trace logs | PRIMARY (id), KEY (user_id), KEY (action) |
wp_omnify_api_keys | REST API consumer keys & permission scopes | PRIMARY (id), UNIQUE KEY (consumer_key) |
Soft Deletion & Caching Engine
Soft deletion is native across all core tables via a nullable deleted_at timestamp. Trashed items are excluded from storefront catalog queries, star rating averages, urgency counters, and public REST queries.
Repositories SDK Reference
All database reads and writes are encapsulated inside typed repository classes.
Product Repository (Omnify_Product_Repository)
$products = $container->get(\Omnify\eCommerce\Repositories\Omnify_Product_Repository::class);
// 1. Filter products with pagination and faceted criteria
$items = $products->all([
'status' => 'published',
'category' => 'Templates',
'type' => 'download',
'price_min' => 10.00,
'price_max' => 120.00,
'stock_status' => 'instock',
'sort' => 'rating_desc',
'per_page' => 20,
]);
// 2. Atomic stock decrement (prevents checkout race conditions)
$success = $products->reduce_stock(
product_id: 10,
variation_id: null,
quantity: 1
);
Order Repository (Omnify_Order_Repository)
$orders = $container->get(\Omnify\eCommerce\Repositories\Omnify_Order_Repository::class);
// Batch-hydrated order listing (eliminates N+1 queries)
$recent_orders = $orders->all([
'status' => 'completed',
'per_page' => 50,
]);
Customer Repository (Omnify_Customer_Repository)
$customers = $container->get(\Omnify\eCommerce\Repositories\Omnify_Customer_Repository::class);
// Find customer by WordPress User ID
$customer = $customers->find_by_user_id(get_current_user_id());
// Record custom CRM event in the customer's timeline
$customers->record_activity(
customer_id: $customer['id'],
activity_type: 'vip_upgrade',
metadata: ['tier' => 'Gold', 'discount' => 0.15]
);
Coupon Repository (Omnify_Coupon_Repository)
$coupons = $container->get(\Omnify\eCommerce\Repositories\Omnify_Coupon_Repository::class);
// Create a single-use 20% discount coupon
$coupon_id = $coupons->create([
'code' => 'SUMMER20',
'discount_type' => 'percentage', // 'percentage' or 'fixed'
'discount_value' => 20.00,
'usage_limit' => 100,
'expires_at' => '2026-12-31 23:59:59',
]);
Storefront & Shortcodes Directory
| Shortcode | Default Slug | Functionality |
|---|---|---|
[omnify_storefront] | /storefront/ | Modern apparel/fashion catalog with interactive Multi-Layout Switcher (4-Col Grid, 2-Col Split, 1-Col List), faceted sidebar filters, slide-in hover tools, and floating social proof conversion widgets. |
[omnify_cart] | /cart/ | Multi-item cart, scarcity countdown timer, shipping zone selector, and coupon application. |
[omnify_mini_cart] | Anywhere | Floating slide-out AJAX mini-cart drawer/dropdown with live line-item quantity adjustment and subtotal calculation. |
[omnify_checkout] | /checkout/ | Frictionless single-page checkout with country-first address autofill and gateway buttons. |
[omnify_customer_portal] | /customer-portal/ | Customer Portal 2.0 hub with SupportHub emerald theme, 4-col KPI cards, live tab pills, cryptographic download locker, and 2-column balanced settings. |
[omnify_customer_downloads] | /downloads/ | Customer digital locker displaying owned files and cryptographically signed download links. |
[omnify_order_tracking] | /order-tracking/ | Order lookup supporting guest tracking with direct digital downloads for paid items. |
[omnify_currency_switcher] | Anywhere | Customer-facing multi-currency selector dropdown with real-time conversion rates and 1-year cookie persistence. |
[omnify_download_page] | /secure-download/ | Dedicated secure template handler for chunked HMAC-SHA256 file delivery. |
Native Gutenberg Blocks
Each shortcode is mirrored as a first-party Gutenberg block (registered in Omnify_Storefront_Controller::register_blocks()): omnify/product-grid, omnify/cart, omnify/mini-cart, omnify/checkout, omnify/customer-portal, omnify/order-tracking, omnify/product-card, and omnify/currency-switcher.
Storefront Multi-Layout Engine & Floating Widgets
The storefront template (templates/storefront/grid.php) renders an ultra-fast, responsive catalog supporting dynamic view switching via data-cols:
data-cols="4")
Clean borderless cards with soft #f6f6f8 image box, pill badges (HOT, -14%, LIMITED), outline wishlist heart, right-edge hover tools (Quick View, Compare), floating sizes (S M), circular plus button, and swatches.
data-cols="2")
Horizontal split layout (46% image / 54% details) featuring star ratings, price, swatches, size row, full-width "Select options" button, and Quick View/Compare links.
data-cols="list")
3-column horizontal row: 220px image, center details (title, rating, swatches, sizes, excerpt), and right panel with price, IN STOCK badge, and action links.
Customer Portal 2.0 Architecture & Theme Variables
The Customer Portal template (templates/storefront/portal.php) uses a dedicated 1360px responsive container and modern SupportHub Emerald design tokens. Theme authors can hook into CSS variables via the omnify_storefront_css_variables filter:
add_filter( 'omnify_storefront_css_variables', function( $vars ) {
$vars['--om-primary'] = '#0f766e'; // Unified Teal
$vars['--om-primary-hover'] = '#115e59';
$vars['--om-success-bg'] = '#f0fdfa';
return $vars;
} );
Storefront.js Client-Side State Machine
Storefront operations run through assets/storefront/storefront.js. Configuration parameters are injected under window.omnifyStorefront.
Payment Gateways Architecture & Webhooks
Secure-by-Default Architecture: By default, all payment gateways are disabled ('0') on fresh installations. Gateways are only exposed to shoppers once valid credentials are provided and the gateway toggle is explicitly activated.
Omnify provides native API integrations and automated webhook verification for:
- Stripe: Credit/Debit, Apple Pay, Google Pay, SEPA (Webhook:
/wp-json/omnify/v1/webhook/stripe— handlespayment_intent.succeeded,charge.refunded,charge.dispute.created) - PayPal Commerce: Smart Buttons, Pay in 4, Venmo (Webhook:
/wp-json/omnify/v1/webhook/paypal— handlesPAYMENT.CAPTURE.COMPLETED,PAYMENT.CAPTURE.REFUNDED,CUSTOMER.DISPUTE.CREATED) - Paddle (Merchant of Record): Automated global tax/VAT compliance across 200+ countries, SaaS billing, Apple Pay, Google Pay, iDEAL, and API refunds (Webhook:
/wp-json/omnify/v1/paddle/webhook— handlestransaction.paid,adjustment.updated) - Paystack: Cards, Mobile Money (M-Pesa, MTN, Airtel), EFT, USSD (Webhook:
/wp-json/omnify/v1/webhook/paystack) - Tap Payments: mada, KNET, Benefit, NAPS, GCC cards (Webhook:
/wp-json/omnify/v1/webhook/tap) - Mollie: iDEAL, Bancontact, SEPA Bank Transfer, Klarna (Webhook:
/wp-json/omnify/v1/webhook/mollie) - Razorpay: UPI, RuPay, NetBanking, Wallets (Webhook:
/wp-json/omnify/v1/webhook/razorpay) - Khalti: Khalti Digital Wallet, Mobile & Net Banking via ePayment v2 API
- eSewa: eSewa Digital Payment Wallet with HMAC-SHA256 signature verification
- Alipay & WeChat Pay: Cross-border mobile QR checkout with callback verification
- SSLCommerz: bKash, Nagad, Rocket, Bangladeshi cards (Webhook:
/wp-json/omnify/v1/webhook/sslcommerz) - Manual & Custom Methods: Cash on Delivery (COD), Direct Bank Transfer (BACS), Cheque Payments, and Unlimited Custom Offline Gateways.
When an admin processes a full refund or a full refund webhook is received, the gateway API is executed, the order transitions to refunded, and all digital file access rights in wp_omnify_customer_access are revoked automatically. For partial refunds, status transitions to partially_refunded, recording refunded amounts while preserving file entitlements for non-refunded line items.
Digital Locker & Chunked Streaming
Download links are protected using HMAC-SHA256 signatures salted with wp_salt('auth'). Binary delivery streams files in 8KB chunks via fread() with output buffers flushed to prevent server memory exhaustion.
Interactive REST API Sandbox & Simulator
Simulate live HTTP requests against Omnify's decoupled endpoints. Select any endpoint to inspect headers, request schemas, parameters, and interactive JSON responses with real-world latency metrics.
// Request Headers
Accept: application/json
Content-Type: application/json
X-WP-Nonce: e9b41a29f8
...
REST API Reference
Namespace: /wp-json/omnify/v1
Storefront Public Endpoints
Administrative Management Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /orders | Paginated orders list with status, date, and customer filters. |
| GET | /orders/{id} | Detailed order information with line items and customer notes. |
| POST | /orders/{id}/mark-paid | Transitions order to paid, reduces stock, and grants downloads. |
| POST | /orders/{id}/trash | Soft-deletes order to trash. |
| POST | /orders/{id}/restore | Restores order from trash. |
| GET | /customers/{id}/activity | Retrieves audit timeline events for a customer. |
| POST | /access | Manually grants digital file access to a customer. |
| POST | /access/revoke | Revokes file download entitlements. |
| POST | /access/bulk | Grants access to multiple customers/products in one request. |
| GET | /settings | Read the full store configuration (POST to update). |
| GET | /stats | Dashboard sales, AOV, refunds, and analytics aggregates. |
| GET | /activity-logs | Administrative security audit feed. |
| GET POST | /delivery-zones | List or update shipping delivery zones. |
| GET POST | /tax-rules | List or update regional tax rate tables. |
| GET | /downloads | List download audit records. |
| GET | /customers/{id}/access | List a customer's digital entitlements. |
| GET | /orders/{id}/history | Status and activity history for an order. |
| POST | /products/{product_id}/files/{file_id}/download-url | Mint an expiring HMAC download URL. |
Checkout, Gateway & Webhook Endpoints
Client-side gateway flows and inbound webhook verification routes (all under /wp-json/omnify/v1).
| Method | Endpoint | Description |
|---|---|---|
| POST | /checkout | Create an order and initiate payment. |
| POST | /stripe/checkout-session • /stripe/payment-intent | Create a Stripe Checkout Session or Payment Intent. |
| POST | /stripe/webhook | Verify Stripe-Signature and sync payment/refund/dispute events. |
| POST | /paypal/order • /paypal/capture • /paypal/webhook | PayPal order creation, capture, and webhook verification. |
| POST | /razorpay/order • /razorpay/verify • /razorpay/webhook | Razorpay payment creation, verification, and webhook. |
| POST | /mollie/order • /mollie/webhook | Mollie payment creation and status webhook. |
| POST | /paddle/order • /paddle/verify • /paddle/webhook | Paddle transaction creation, verification, and webhook. |
| POST | /paystack/order • /paystack/verify • /paystack/webhook | Paystack initiation, verification, and HMAC-SHA512 webhook. |
| POST | /tap/order • /tap/verify • /tap/webhook | Tap Payments charge, verification, and webhook. |
| POST | /alipay/order • /alipay/verify • /alipay/webhook | Alipay trade creation, verification, and RSA2 notify. |
| POST | /wechat/order • /wechat/verify • /wechat/webhook | WeChat Pay unified order, verification, and v3 notify. |
| POST | /sslcommerz/order • /sslcommerz/verify • /sslcommerz/ipn | SSLCommerz session, validation, and IPN. |
| POST | /khalti/order • /khalti/verify | Khalti ePayment v2 initiation and lookup verification. |
| POST | /esewa/order • /esewa/verify | eSewa ePay v2 initiation and HMAC verification. |
Interactive Hooks & Filters Live Explorer
55+ Hooks IndexedSearch and filter all available actions, filters, and public developer helper functions. Click any card to copy the ready-to-paste PHP code snippet directly into your functions.php or custom plugin.
Action Hooks Directory
Action hooks let you execute custom logic when specific events happen inside Omnify.
| Action Hook | Arguments | Fires When |
|---|---|---|
omnify_before_boot | $plugin, $container | Fires before Omnify registers internal services and repositories. |
omnify_booted | $plugin, $container | Fires after full bootstrap is complete. |
omnify_order_created | $order_id, $order_data | Fires immediately after an order is recorded in the database. |
omnify_order_status_changed | $order_id, $new_status, $old_status | Fires when an order transitions between statuses (e.g. pending → completed). |
omnify_customer_access_granted | $customer_id, $product_id, $expires_at, $id | Fires when digital product downloads are granted to a customer. |
omnify_customer_access_revoked | $customer_id, $product_id | Fires when access is revoked upon refund or cancellation. |
omnify_download_logged | $log_id, $product_id, $file_id, $customer_id, $status | Fires after a customer downloads a protected file. |
omnify_stock_reduced | $product_id, $variation_id, $qty, $new_stock | Fires after atomic stock reduction on checkout. |
add_action('omnify_order_status_changed', function($order_id, $new_status, $old_status) {
if ('processing' === $new_status || 'completed' === $new_status) {
// Fetch order details from repository
$order = omnify()->container()->get(\Omnify\eCommerce\Repositories\Omnify_Order_Repository::class)->find($order_id);
// Log custom message or dispatch external fulfillment
error_log("Order #{$order_id} is ready for fulfillment for {$order['email']}");
}
}, 10, 3);
Filter Hooks Directory
Filter hooks allow developers to intercept, modify, and return customized data throughout the Omnify engine without modifying a single core file. Whenever Omnify formats prices, processes checkout submissions, queries products, or streams digital files, it passes the data through these hooks.
| Filter Hook | Parameters | Return Type | Primary Use Case |
|---|---|---|---|
omnify_format_price |
$formatted, $amount, $settings |
string |
Customize currency display, append VAT notes, display "FREE" badges, or perform dynamic multi-currency conversions. |
omnify_before_checkout_validation |
$data, $settings, $items |
array |
Normalize or sanitize form inputs (e.g. phone numbers), apply cart-wide volume tier discounts, or inject session variables. |
omnify_after_checkout_validation |
$error, $data, $settings, $items |
null|WP_Error |
Halt checkout by returning a WP_Error. Enforce minimum order values, block disposable emails, or validate VAT/tax IDs. |
omnify_get_products_args |
$args |
array |
Modify product query arguments. Automatically hide out-of-stock items or gate VIP/wholesale products by user role. |
omnify_get_orders_args |
$args |
array |
Filter order listings in admin or customer portals (e.g. by customer tier, status, or date range). |
omnify_signed_download_expires_in |
$seconds, $file_id, $customer_id |
int |
Adjust the lifetime (default: 900s / 15m) of HMAC-SHA256 download links. Offer 48-hour windows for VIP members. |
omnify_rest_can_manage |
$can_manage, $request, $user_id |
bool|WP_Error |
Authorize external ERP microservices, inventory sync bots, or headless services via custom API keys or Bearer tokens. |
omnify_email_arguments |
$args |
array |
Intercept transactional emails. Attach PDF invoices, customize HTML templates, or add accounting team BCC addresses. |
Detailed Filter Hook Guides & Practical Examples
omnify_format_price($formatted, $amount, $settings)
How it works: Every price string rendered by Omnify across storefront cards, quick-view modals, cart drawers, checkout summaries, and email confirmations passes through this filter. You can rewrite the text, append tax notices, or convert the currency symbol.
$formatted (string) — Formatted price HTML/text (e.g., "$49.00") • $amount (float) — Raw numerical price (e.g., 49.00) • $settings (array) — Active store currency and formatting options.
/**
* Display a stylish "FREE" badge instead of "$0.00" for giveaway digital goods.
*/
add_filter('omnify_format_price', function($formatted, $amount, $settings) {
if ((float) $amount === 0.0) {
return '<span class="badge-free" style="color:#10b981; font-weight:700;">FREE</span>';
}
return $formatted;
}, 10, 3);
/**
* Append international ISO code (e.g. USD) and VAT tax indicator.
*/
add_filter('omnify_format_price', function($formatted, $amount, $settings) {
$currency = $settings['currency'] ?? 'USD';
return $formatted . " <span style=\"font-size:0.8em; color:#94a3b8;\">{$currency} (incl. VAT)</span>";
}, 10, 3);
omnify_before_checkout_validation($data, $settings, $items)
How it works: Executes before Omnify performs required-field verification. Use this to sanitize and clean user inputs, normalize phone numbers to international standard, or modify cart data.
$data (array) — Form submission keys (first_name, email, address, custom fields) • $settings (array) — Store options • $items (array) — Line items in cart.
/**
* Standardize customer phone numbers to digits only and strip spaces.
*/
add_filter('omnify_before_checkout_validation', function($data, $settings, $items) {
if (! empty($data['phone'])) {
// Strip all non-numeric characters except leading plus '+'
$data['phone'] = preg_replace('/[^\d+]/', '', $data['phone']);
}
// Sanitize customer delivery notes if provided
if (! empty($data['delivery_notes'])) {
$data['delivery_notes'] = sanitize_textarea_field($data['delivery_notes']);
}
return $data;
}, 10, 3);
omnify_after_checkout_validation($error, $data, $settings, $items)
How it works: The most crucial hook for custom business rules. Fires after all core validations pass. If you return null, the checkout succeeds. If you return a WP_Error object, checkout immediately stops and your message is highlighted in red on the checkout screen.
$error (null|\WP_Error) — Initial state • $data (array) — Validated checkout data • $settings (array) — Store settings • $items (array) — Line items.
/**
* Block checkout if the customer's total purchase is less than $25.00.
*/
add_filter('omnify_after_checkout_validation', function($error, $data, $settings, $items) {
$subtotal = 0.0;
foreach ($items as $item) {
$subtotal += (float) ($item['price'] ?? 0) * (int) ($item['quantity'] ?? 1);
}
if ($subtotal < 25.00) {
return new \WP_Error(
'subtotal_too_low',
__('Our store requires a minimum purchase subtotal of $25.00.', 'my-store')
);
}
return $error;
}, 10, 4);
/**
* Reject temporary disposable emails (e.g. mailinator, tempmail) to protect digital downloads.
*/
add_filter('omnify_after_checkout_validation', function($error, $data) {
$email = strtolower(trim($data['email'] ?? ''));
$blocked_domains = ['mailinator.com', 'tempmail.com', '10minutemail.com', 'guerrillamail.com'];
foreach ($blocked_domains as $domain) {
if (str_ends_with($email, '@' . $domain)) {
return new \WP_Error(
'blocked_email_provider',
__('Temporary or disposable email addresses are not permitted. Please use your real email.', 'my-store')
);
}
}
return $error;
}, 10, 2);
omnify_get_products_args($args)
How it works: Intercepts parameters sent to Omnify_Product_Repository::all(). Use this to automatically filter storefront query results without modifying templates.
/**
* Enforce in-stock only for visitors, and restrict category 'wholesale' to B2B users.
*/
add_filter('omnify_get_products_args', function($args) {
// 1. Always hide out of stock items on public frontend
if (! is_admin()) {
$args['stock_status'] = 'instock';
}
// 2. If user is NOT a verified wholesale buyer, exclude wholesale catalog
if (! current_user_can('wholesale_buyer')) {
$args['exclude_category'] = 'wholesale-exclusive';
}
return $args;
});
omnify_signed_download_expires_in($seconds, $file_id, $customer_id)
How it works: Omnify signs digital downloads using HMAC-SHA256 to stop link piracy. By default, links expire after 900 seconds (15 minutes). Use this hook to lengthen or shorten the window depending on file size or customer status.
/**
* VIP customers get 48 hours (172,800s); regular customers get 1 hour (3,600s).
*/
add_filter('omnify_signed_download_expires_in', function($seconds, $file_id, $customer_id) {
$customer = omnify()->container()->get(\Omnify\eCommerce\Repositories\Omnify_Customer_Repository::class)->find($customer_id);
if ($customer && ($customer['group'] ?? '') === 'vip') {
return 172800; // 48 hours in seconds
}
return 3600; // 1 hour for standard customers
}, 10, 3);
omnify_rest_can_manage($can_manage, $request, $server)
How it works: Controls administrative access to REST API routes under /wp-json/omnify/v1/. Return true to grant authorization, or return a WP_Error to deny access. Perfect for headless systems and automated ERP bots.
/**
* Allow automated inventory sync bot using a custom Bearer token.
*/
add_filter('omnify_rest_can_manage', function($can_manage, $request) {
$auth_header = $request->get_header('authorization') ?? '';
$secret_token = 'erp_live_sec_994827104829104820';
if (hash_equals('Bearer ' . $secret_token, $auth_header)) {
return true; // Authorized external sync
}
return $can_manage;
}, 10, 2);
omnify_email_arguments($args)
How it works: Intercepts transactional emails before dispatch. You can add BCC headers for internal order archiving or attach PDF receipts and license agreements.
/**
* Automatically BCC accounting team on all order confirmation emails.
*/
add_filter('omnify_email_arguments', function($args) {
if (str_contains($args['subject'] ?? '', 'Order Confirmation')) {
$args['headers'][] = 'Bcc: accounting@my-company.com';
}
return $args;
});
Developer Recipes & Real-World Guides
Complete, production-tested, copy-pasteable step-by-step guides for extending Omnify in real-world commercial WordPress deployments.
Custom Checkout Fields (VAT / Tax ID & Delivery Instructions)
Problem: You need B2B customers to enter a European VAT ID or shipping instructions on checkout, validate it, and store it visibly in the order history.
/**
* Step 1: Validate custom VAT number during checkout.
*/
add_filter('omnify_after_checkout_validation', function($error, $data) {
$vat = trim($data['vat_number'] ?? '');
// If customer provided a VAT ID, ensure it has at least 8 alphanumeric characters
if (! empty($vat) && strlen($vat) < 8) {
return new \WP_Error('invalid_vat', __('Please provide a valid VAT / Tax registration ID.', 'my-theme'));
}
return $error;
}, 10, 2);
/**
* Step 2: Save custom VAT and delivery instructions into Order Notes upon creation.
*/
add_action('omnify_order_created', function($order_id, $order_data) {
$orders = omnify()->container()->get(\Omnify\eCommerce\Repositories\Omnify_Order_Repository::class);
if (! empty($_POST['vat_number'])) {
$vat = sanitize_text_field(wp_unslash($_POST['vat_number']));
$orders->add_note($order_id, "Customer VAT / Tax ID: {$vat}", customer_visible: true);
}
if (! empty($_POST['delivery_notes'])) {
$notes = sanitize_textarea_field(wp_unslash($_POST['delivery_notes']));
$orders->add_note($order_id, "Delivery Instructions: {$notes}", customer_visible: true);
}
}, 10, 2);
Real-Time Discord or Slack Order Alerts
Problem: Your operations team needs an instant rich notification in Discord or Slack whenever a customer completes a purchase.
/**
* Send real-time webhook alert to Discord or Slack when an order is paid.
*/
add_action('omnify_order_status_changed', function($order_id, $new_status) {
// Trigger only when order reaches 'completed' or 'processing'
if (! in_array($new_status, ['completed', 'processing'], true)) {
return;
}
$order = omnify()->container()->get(\Omnify\eCommerce\Repositories\Omnify_Order_Repository::class)->find($order_id);
if (! $order) {
return;
}
$webhook_url = 'https://discord.com/api/webhooks/YOUR_WEBHOOK_URL_HERE';
$payload = [
'embeds' => [
[
'title' => "[Order] New Order #{$order_id} Received!",
'color' => 3921912, // Emerald green
'description' => "**Customer:** {$order['billing_first_name']} {$order['billing_last_name']} ({$order['email']})\n"
. "**Total:** {$order['currency']} \${$order['total']}\n"
. "**Gateway:** {$order['payment_method']}\n"
. "**Status:** {$new_status}",
'timestamp' => date('c')
]
]
];
wp_remote_post($webhook_url, [
'headers' => ['Content-Type' => 'application/json'],
'body' => wp_json_encode($payload),
'blocking' => false, // Non-blocking async dispatch for maximum performance
'timeout' => 5,
]);
}, 10, 2);
Headless Next.js 14 / React Catalog & Headless Checkout
Problem: You want a lightning-fast React frontend querying Omnify's public endpoints using Next.js Incremental Static Regeneration (ISR) and server components.
// app/products/page.tsx (Next.js 14 App Router Server Component)
interface Product {
id: number;
name: string;
slug: string;
price: number;
sale_price: number | null;
stock_status: string;
}
export default async function ProductsPage() {
const res = await fetch('https://your-site.com/wp-json/omnify/v1/products/public?per_page=12', {
next: { revalidate: 60 } // Revalidate every 60 seconds (ISR)
});
const products: Product[] = await res.json();
return (
<div className="max-w-6xl mx-auto py-12 px-4">
<h1 className="text-3xl font-extrabold mb-8">Product Catalog</h1>
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-6">
{products.map((p) => (
<div key={p.id} className="border border-slate-800 rounded-xl p-5 bg-slate-900">
<h3 className="font-bold text-lg text-white">{p.name}</h3>
<p className="text-sky-400 font-semibold text-xl mt-2">
${p.sale_price ?? p.price}
</p>
<a href={`/products/${p.slug}`} className="block mt-4 text-center bg-sky-500 hover:bg-sky-400 text-slate-950 font-bold py-2 rounded-lg">
View Details
</a>
</div>
))}
</div>
</div>
);
}
Auto-Generating & Emailing Software License Keys
Problem: When a customer purchases software or plugins, you want to automatically mint a formatted license key (XXXX-XXXX-XXXX-XXXX) and email it to them.
/**
* Automatically mint a 16-character license key upon digital access grant.
*/
add_action('omnify_customer_access_granted', function($customer_id, $product_id) {
// Format: XXXX-XXXX-XXXX-XXXX
$raw_bytes = random_bytes(8);
$hex_string = strtoupper(bin2hex($raw_bytes));
$license_key = implode('-', str_split($hex_string, 4));
// Retrieve customer details
$customer = omnify()->container()->get(\Omnify\eCommerce\Repositories\Omnify_Customer_Repository::class)->find($customer_id);
if (! $customer) {
return;
}
// Store license key in customer options
update_user_meta($customer['user_id'] ?? 0, "omnify_license_{$product_id}", $license_key);
// Dispatch email to customer
$subject = 'Your Software License Activation Key';
$message = "Hello {$customer['first_name']},\n\n"
. "Thank you for your order! Here is your official activation license key:\n\n"
. " {$license_key}\n\n"
. "You can download your product files anytime from your customer account portal.\n\n"
. "Best regards,\nThe Team";
wp_mail($customer['email'], $subject, $message);
}, 10, 2);
Tiered Bulk Volume Discount Engine
Problem: You want an automated volume promotion: Buy 3+ items and get 10% off, buy 5+ items and get 20% off total cart value.
/**
* Automatically adjust cart subtotal based on volume quantity.
*/
add_filter('omnify_before_checkout_validation', function($data, $settings, $items) {
$total_qty = 0;
foreach ($items as $item) {
$total_qty += (int) ($item['quantity'] ?? 1);
}
// Apply 20% discount for 5+ items, or 10% for 3+ items
$discount_rate = 0.0;
if ($total_qty >= 5) {
$discount_rate = 0.20;
} elseif ($total_qty >= 3) {
$discount_rate = 0.10;
}
if ($discount_rate > 0) {
$data['volume_discount_rate'] = $discount_rate;
}
return $data;
}, 10, 3);
Custom Offline Bank Wire Transfer / Direct Invoice Method
Problem: You need an offline "Wire Transfer / Invoice" payment method that puts orders in on-hold status until wire verification, displaying wire instructions to the customer.
/**
* Set custom wire transfer orders to 'on-hold' status and append bank details.
*/
add_action('omnify_order_created', function($order_id, $order_data) {
if (($order_data['payment_method'] ?? '') === 'wire_transfer') {
$orders = omnify()->container()->get(\Omnify\eCommerce\Repositories\Omnify_Order_Repository::class);
// Set status to 'on-hold' until bank funds clear
$orders->update($order_id, ['status' => 'on-hold']);
// Add wire instructions for customer view
$orders->add_note(
$order_id,
'Bank: Chase Bank | Account: #987654321 | Routing: #123456789. Please mention Order #' . $order_id,
customer_visible: true
);
}
}, 10, 2);
Dynamic Multi-Currency Pricing with Live Geo-Location
Problem: Show European customers prices in EUR (€) and UK customers prices in GBP (£) dynamically based on visitor IP address.
/**
* Dynamically convert base USD amounts to EUR or GBP based on Cloudflare or IP headers.
*/
add_filter('omnify_format_price', function($formatted, $amount, $settings) {
$country = $_SERVER['HTTP_CF_IPCOUNTRY'] ?? 'US';
if (in_array($country, ['FR', 'DE', 'IT', 'ES', 'NL'], true)) {
// EUR conversion rate (e.g. 1 USD = 0.92 EUR)
$eur_price = number_format($amount * 0.92, 2);
return "€{$eur_price} EUR";
}
if ($country === 'GB') {
// GBP conversion rate (e.g. 1 USD = 0.79 GBP)
$gbp_price = number_format($amount * 0.79, 2);
return "£{$gbp_price} GBP";
}
return $formatted;
}, 10, 3);
Restricting Digital Downloads by Maximum Download Count
Problem: Prevent customers from sharing digital download links by capping file access to a maximum of 5 downloads per customer.
/**
* Enforce a strict 5-download limit per digital product file.
*/
add_filter('omnify_signed_download_expires_in', function($seconds, $file_id, $customer_id) {
global $wpdb;
$table = $wpdb->prefix . 'omnify_download_logs';
// Count successful past downloads for this customer and file
$download_count = (int) $wpdb->get_var($wpdb->prepare(
"SELECT COUNT(*) FROM {$table} WHERE customer_id = %d AND file_id = %d AND status = 'success'",
$customer_id,
$file_id
));
if ($download_count >= 5) {
// Return 0 to immediately invalidate and expire the link
wp_die(__('You have reached the maximum allowed downloads (5/5) for this file. Please contact support.', 'my-store'), 403);
}
return $seconds;
}, 10, 3);
Roles, Capabilities & Staff Permissions
Omnify ships a granular, per-feature permission model so store owners can delegate operations without granting full WordPress administrator rights.
| Capability | Granted To | Meaning |
|---|---|---|
manage_omnify | Administrators + mapped roles | Master capability gating the entire Omnify admin. |
manage_omnify_{feature} | Roles mapped per feature | Scoped access to a single feature area (computed dynamically, never persisted). |
Feature scopes: dashboard, orders, products, customers, coupons, abandoned_carts, reviews, analytics. Two roles are auto-created on first boot: shop_manager and shop_clerk.
$settings = get_option('omnify_settings', []);
$settings['role_permissions'] = array_merge((array) ($settings['role_permissions'] ?? []), [
'orders' => ['administrator', 'shop_manager', 'shop_clerk'],
'reviews' => ['administrator', 'shop_manager', 'shop_clerk'],
]);
update_option('omnify_settings', $settings);
Analytics & Conversion Tracking (GA4 + Meta Pixel)
Omnify_Tracking_Service injects first-party GA4 and Meta Pixel tags, driven by Settings → Marketing (keys tracking_ga4_enabled, tracking_ga4_measurement_id, tracking_meta_enabled, tracking_meta_pixel_id, tracking_debug_mode).
| Provider | Events Tracked |
|---|---|
| GA4 | view_item_list, view_item, add_to_cart, begin_checkout, purchase (with transaction_id, value, currency, items). |
| Meta Pixel | PageView, ViewContent, AddToCart, InitiateCheckout, Purchase. |
Runtime hooks: wp_enqueue_scripts (gtag/fbq bootstrap) and wp_body_open (Meta noscript). Values flow to the storefront through window.omnifyStorefront.analytics.
Privacy, GDPR & Data Lifecycle
Omnify_Privacy_Service integrates with the WordPress core privacy framework: a Personal Data Exporter and Eraser (friendly name Omnify) cover customer profiles, orders, order items, downloads, wishlists, and abandoned carts.
- Soft deletes: nullable
deleted_atexcludes records from storefront & public queries. - Automated maintenance: cron
omnify_daily_database_cleanupprunes expired carts and stale sessions. - Email logs:
wp_omnify_email_logsretains dispatch history and retry state. - Download audit:
wp_omnify_downloadslogs IP, user agent, and status per delivery.
Shipping Zones, Tax Rules & Multi-Currency
Delivery zones (delivery_zones setting + /delivery-zones REST route) and tax tables (/tax-rules REST route) are fully data-driven. Multi-currency conversion is handled by Omnify_Locations and the [omnify_currency_switcher] shortcode.
| Filter | Purpose |
|---|---|
omnify_currency_exchange_rates | Override the full FX rate table (e.g. sync from an API). |
omnify_currency_exchange_rate | Override a single from→to rate. |
omnify_converted_currency_amount | Post-process a converted amount before formatting. |
omnify_currency_symbol / omnify_currency_decimals | Override symbol or decimal precision per currency. |
omnify_allowed_countries / omnify_countries / omnify_states | Control storefront selling and address geography. |
Product Variations, Availability & Preorders
Variable products span wp_omnify_products (parent) and wp_omnify_product_variations (matrix). Availability is column-driven rather than a single stock field.
| Column | Purpose |
|---|---|
manage_stock, stock_qty, stock_status | Numeric inventory tracking (instock / outofstock / onbackorder). |
allow_backorders | Permit purchases when out of stock. |
preorder_enabled, preorder_release_date, preorder_limit, preorder_message | Preorder scheduling and shopper notices. |
estimated_delivery (variations) | Per-variation dispatch estimate. |
Related hooks: omnify_stock_reduced, omnify_product_restocked, omnify_customer_access_granted, omnify_customer_access_revoked.
Background Jobs, Cron & Maintenance
| Scheduled Hook | Frequency | Responsibility |
|---|---|---|
omnify_abandoned_cart_recovery | Hourly | Scans abandoned carts and dispatches recovery emails. |
omnify_daily_database_cleanup | Daily | Prunes expired carts, stale checkouts, and optimizes indexes. |
omnify_retry_failed_emails | Hourly | Re-dispatches failed sends logged in wp_omnify_email_logs. |
omnify_prune_webhook_logs | Daily | Trims old wp_omnify_webhook_delivery_logs rows. |
Both the recovery and webhook-prune events are unscheduled on plugin deactivation (Omnify_Plugin::deactivate()).
Admin Pages & Settings Reference
Every screen lives under the top-level Omnify menu, gated by manage_omnify. The Settings hub is segmented into the tabs below; the same slug list gates which keys a save request may modify.
| Settings Tab | Notable Settings |
|---|---|
general | Store name, base country, selling locations, currency, price formatting, tax defaults, test mode. |
pages | Core page mapping (Storefront/Cart/Checkout/Portal/Download/Tracking) + auto page setup. |
roles | Minimum capability, feature permissions matrix, staff directory. |
payments | 12 gateways + offline methods, modes, keys, webhook URLs. |
tax | Tax defaults + regional tax rule table. |
delivery | Zones, method type, cost, free-shipping minimum. |
checkout | Guest/account handling, stock hold, order number format, coupons, order bump, downloads, terms, refunds. |
fraud | Country mismatch, disposable email, high-value threshold, IP velocity. |
marketing | GA4 + Meta Pixel and debug logging. |
design | Brand colors, typography, hero, catalog layout, filters, product card. |
email | 17 triggers, SMTP relay, routing, footer. |
tools | Optimize tables, clear transients, purge carts, inventory resync. |
CSV & XML Import/Export Schema
Move records in and out under Omnify → Import / Export as schema-validated CSV (or XML for products). Column order does not matter; unknown columns are ignored.
| Entity | Required | Full Header Set |
|---|---|---|
| Products | name | name, slug, type, product_kind, sales_type, price, sale_price, currency, sku, status, stock_status, manage_stock, stock_qty, allow_backorders, preorder_enabled, preorder_release_date, preorder_limit, preorder_message, shipping_class, weight, length, width, height, download_expiry_days, categories, tags, description |
| Customers | email | email, first_name, last_name, status, phone, company, country, tax_exempt |
| Orders | order_number, customer_email | order_number, customer_email, status, currency, subtotal, tax, shipping_total, total, payment_method, coupon_code, discount_amount |
| Coupons | code, discount_type, discount_value | code, is_active, discount_type, discount_value, min_order_amount, max_discount_amount, usage_limit, usage_limit_per_customer, free_shipping, first_order_only, included_product_ids, excluded_product_ids, included_categories, excluded_categories, expires_at |
| Tax Rules | label, country, state, rate | enabled, label, country, state, rate, priority, reporting_code |
| Delivery Zones | name, countries, states, method_name | enabled, name, countries, states, method_name, method_type, cost, free_min, class_costs, priority |
Performance, Caching & Scaling
- Normalized indexed tables — avoids
wp_postmetaEAV joins; single-query lookups. - Batch hydration —
Product_File_Repository::all_for_products()removes N+1 file queries. - Object cache group —
omnifywp-ecommercecaches product/slug/sku/customer lookups. - Compound indexes —
omnify_orders(status, created_at,customer_id, status, created_at). - Atomic stock ops —
reduce_stock()prevents oversell under concurrency. - Chunked downloads — 8KB streaming buffers for large files.
- <35KB frontend script footprint plus deferred maintenance crons.
Security Model & Hardening
- Capability gating — every admin/REST management route requires
manage_omnify(or a scoped capability) / a valid API key. - REST auth — nonce, HTTP Basic,
X-Consumer-Key/X-Consumer-Secret, or query params. - Secure-by-default gateways — disabled until credentials are saved.
- Webhook verification — Stripe/PayPal/Razorpay/Paystack/Paddle signatures, Alipay RSA2, WeChat AES-256-GCM.
- Download protection — HMAC-SHA256 tokens,
realpath()containment, path normalization.
location ^~ /wp-content/uploads/omnify-protected/ {
internal;
return 403;
}
Glossary
| Term | Meaning |
|---|---|
| Bundle | A curated product composed of multiple catalog items sold as one discounted SKU. |
| Customer Access | A row in wp_omnify_customer_access granting entitlement to a digital product. |
| Delivery Zone | A shipping rule scoped by country/region with a rate type. |
| HMAC Token | A signed, expiring download URL concealing the physical file path. |
| Order Bump | A one-click upsell offered directly on the checkout form. |
| Preorder | A product/variation sold before release, with optional limits and notices. |
| Soft Delete | A nullable deleted_at flag that hides a record without purging it. |
| Trigger | A named automated email dispatched at a lifecycle event. |
| Webhook Event | An inbound gateway callback recorded in wp_omnify_webhook_events. |