A US-based wholesale distributor needed WooCommerce to function as a fully gated B2B platform — minimum order quantities enforced at checkout, tiered pricing per buyer account tier, and a complete wholesale account approval workflow. Every requirement was built from first principles using WooCommerce core, custom user roles, and PHP hooks.
Standard WooCommerce is built for retail — single price, single buyer type, no approval gates. The client needed something entirely different: a locked-down B2B platform where pricing, access, and purchasing rules all differed by buyer tier.
WooCommerce out of the box has no concept of wholesale. No buyer verification, no MOQ enforcement, no account-level pricing tiers — and every plugin solution came with bloat, conflicts, or recurring licence costs the client refused.
I built a complete B2B layer on top of WooCommerce using custom WordPress user roles, product-level meta fields for tiered pricing and MOQ, and a multi-step account application system — all in clean, hook-driven PHP with zero plugin dependencies.
Every major wholesale plugin (Wholesale Suite, B2B King, etc.) adds dozens of database queries per page load and locks you into their data structures. A custom role-based approach stores tier data directly on the user object, runs a single user meta check per request, and costs nothing per seat or per year — permanently. Leaner, faster, and client-owned forever.
Each feature was scoped, architected, and tested individually before integration — ensuring a stable, conflict-free system across all buyer tiers and product types.
Three wholesale roles — Silver, Gold, and Platinum — each with a distinct price stored as product meta. The WooCommerce price filter hook (woocommerce_get_price) checks the buyer's role at render time and serves the correct price. Retail visitors see a blurred placeholder and a "Request Wholesale Access" prompt — no price leaked, ever.
Tiered price filter — serves role-specific pricing at the WooCommerce data layer:
// Intercept WooCommerce price at the data layer — before display, cart, or emails add_filter( 'woocommerce_get_price', 'get_wholesale_price_for_role', 10, 2 ); function get_wholesale_price_for_role( $price, $product ) { // Map each wholesale role to its product meta key $role_price_map = [ 'wholesale_silver' => '_price_silver', 'wholesale_gold' => '_price_gold', 'wholesale_platinum' => '_price_platinum', ]; foreach ( $role_price_map as $role => $meta_key ) { if ( current_user_can( $role ) ) { $tier_price = get_post_meta( $product->get_id(), $meta_key, true ); // Only override if a tier price has been set for this product if ( $tier_price !== '' ) return (float) $tier_price; } } return $price; // Retail fallback — price remains hidden via front-end gate }
MOQ is set per product via a custom product tab with a numeric input field. Enforcement runs at three independent layers: the add-to-cart action (blocked with inline notice), the cart update handler (corrects or rejects the quantity), and a final checkout validation pass — ensuring no order slips through even if a buyer manipulates cart values directly.
A custom multi-step application form (business name, reseller licence, intended purchase volume, Amazon seller ID) feeds into a custom admin management screen. On submission, the admin receives an email with a one-click approve or reject action. Approved buyers are automatically promoted to their assigned role tier. Rejected applicants receive a branded decline email with a reason field.
Each product has three custom meta fields: wholesale unit cost, estimated Amazon sale price, and FBA fulfilment fee. The product page renders a live ROI margin card visible only to approved wholesale buyers — showing estimated profit per unit, profit margin percentage, and break-even quantity — giving FBA sellers the data they need to make instant purchasing decisions.
The entire system is orchestrated through WooCommerce filter and action hooks — no database schema changes, no REST API overrides, no frontend framework dependencies.
On every product page and shop archive, a single get_user_meta call checks the current user's wholesale role. If the role is not one of the three approved wholesale tiers, the price display is replaced with a styled "Request Wholesale Access" component and all add-to-cart functionality is hidden. Zero performance overhead — one query, resolved from WordPress object cache.
The woocommerce_get_price filter intercepts the default price query and returns the role-specific price from product meta instead. Simultaneously, a custom action hook renders the ROI margin card below the add-to-cart block — showing the buyer their expected profit per unit at their current role's price point.
When a buyer adds to cart, woocommerce_add_to_cart_validation checks quantity against the product's MOQ meta. If below MOQ, the add-to-cart is blocked with a descriptive notice. The same check runs on cart updates and is repeated server-side during checkout processing — ensuring a buyer cannot bypass MOQ by editing the URL or using the WooCommerce REST API directly.
The application form POSTs to a custom handler that stores the application as a custom post type with status "pending". The admin receives an email with a direct deep-link to the application review page. Clicking "Approve" calls wp_update_user with the assigned role, sends the buyer a welcome email with login credentials, and updates the application status — all in a single server-side action.
One-click approval handler — promotes buyer role, sends welcome email, and updates application status atomically:
// Fires when admin clicks "Approve" on the application review screen add_action( 'admin_post_approve_wholesale_application', 'handle_wholesale_approval' ); function handle_wholesale_approval() { $application_id = (int) $_GET['application_id']; $assigned_tier = get_post_meta( $application_id, '_assigned_tier', true ); $user_id = (int) get_post_meta( $application_id, '_applicant_user_id', true ); // 1. Promote the user to their approved wholesale role tier $user = new WP_User( $user_id ); $user->set_role( $assigned_tier ); // 2. Update application CPT status to 'approved' wp_update_post([ 'ID' => $application_id, 'post_status' => 'approved' ]); // 3. Send branded welcome email with login link wp_mail( get_userdata( $user_id )->user_email, __( 'Your Wholesale Account Has Been Approved', 'wholesale' ), build_approval_email( $user_id, $assigned_tier ), [ 'Content-Type: text/html; charset=UTF-8' ] ); wp_safe_redirect( admin_url( 'edit.php?post_type=wholesale_application&approved=1' ) ); exit; }
All per-product configuration (MOQ, Silver/Gold/Platinum prices, FBA fee, estimated sale price) is managed via a custom product data tab injected into the standard WooCommerce product editor using woocommerce_product_data_panels — no separate admin pages, no separate URLs, no user training burden.
MOQ enforcement — the core validation hook that blocks below-minimum add-to-cart attempts:
// Layer 1: Block add-to-cart if quantity is below MOQ add_filter( 'woocommerce_add_to_cart_validation', 'enforce_moq_on_add_to_cart', 10, 3 ); function enforce_moq_on_add_to_cart( $passed, $product_id, $quantity ) { // Only enforce for approved wholesale buyers if ( ! current_user_has_wholesale_role() ) return $passed; $moq = (int) get_post_meta( $product_id, '_wholesale_moq', true ); // No MOQ set — allow unrestricted purchase if ( $moq <= 0 ) return $passed; if ( $quantity < $moq ) { wc_add_notice( sprintf( __( 'Minimum order quantity for this product is %d units.', 'wholesale' ), $moq ), 'error' ); return false; // Block add-to-cart } return $passed; }
Every component relies exclusively on WordPress and WooCommerce core APIs — no third-party packages, no external database tables, and no frontend framework dependencies.
Three wholesale roles registered via add_role() on activation — Silver, Gold, Platinum — each with scoped capabilities and clean removal on plugin deactivation.
The woocommerce_get_price and woocommerce_get_regular_price filters intercept pricing at the data layer — ensuring tiered prices appear correctly in shop, single product, cart, order emails, and admin screens.
Add-to-cart, cart update, and checkout-processing hooks each independently validate MOQ — making the system resilient to REST API calls, page reloads, and direct cart manipulation.
Wholesale account applications are stored as a CPT with a structured meta schema — making them queryable, filterable, and manageable from a dedicated admin list table with bulk approve/reject actions.
All product-level wholesale configuration — MOQ, tier prices, FBA cost, estimated Amazon sale price — is managed via a custom tab in the standard WooCommerce product editor, keeping the admin experience native and familiar.
The ROI margin card is rendered server-side using PHP arithmetic on product meta values — no JavaScript dependency, no AJAX request, and no risk of exposing cost data to non-wholesale users via client-side inspection.
A production-grade B2B wholesale platform built entirely on WooCommerce — no plugin subscriptions, no vendor lock-in, and complete control over every business rule encoded in the system.
Retail visitors see zero prices. Approved buyers see role-specific pricing. The gate is enforced at the PHP layer — not CSS, not JavaScript — so there is no way to inspect or bypass it.
Triple-layer enforcement means no order has ever been placed below MOQ — not through the storefront, not through the WooCommerce API, not through any cart manipulation technique.
The account approval workflow reduced the client's onboarding time from manual email threads to a single-click admin action — with automatic role assignment, welcome emails, and application audit trail included.
Displaying per-product profit margin and FBA cost data at the point of purchase gives buyers confidence to commit to larger quantities — the client saw average order value increase from the first week the ROI card was live.
"B2B eCommerce is a fundamentally different problem from retail — different buyer psychology, different trust requirements, different data needs at the point of purchase. This system was engineered to match those requirements exactly, not hammered into a retail-first plugin's limitations."
I build wholesale and B2B WooCommerce systems from scratch — MOQ rules, tiered pricing, buyer approval flows, and FBA tools — all owned by you with zero recurring plugin costs.