WordPress / WooCommerce Custom PHP Development B2B eCommerce Wholesale Portal

Custom Multi-Vendor
Wholesale Portal — MOQ · Tiered Pricing · Buyer Approval.

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.

Result: A fully gated wholesale store — retail customers see no prices, approved wholesale buyers get tiered pricing, and MOQ is enforced at every point in the purchase flow.

Problem & Solution

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.

The Challenge

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.

  • Retail visitors could see wholesale pricing — a serious business problem
  • No minimum order quantity enforcement at product or cart level
  • No way to set different prices for Silver, Gold, and Platinum buyer tiers
  • No application or approval flow for new wholesale accounts
  • ROI margin data for FBA sellers needed to show per-product — not supported natively

The Solution

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.

  • Three wholesale roles: Silver, Gold, Platinum — each with distinct pricing
  • MOQ enforced at add-to-cart, cart update, and checkout validation layers
  • Retail visitors see no prices — a "Request Access" gate is shown instead
  • Admin-managed account approval workflow with email notifications
  • Per-product ROI margin + FBA cost data fields with live display to buyers
💡

Why Custom Roles Beat WooCommerce Wholesale Plugins

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.


Four Engineering Pillars

Each feature was scoped, architected, and tested individually before integration — ensuring a stable, conflict-free system across all buyer tiers and product types.

1
Feature 01 — Pricing Layer
Tiered Pricing

Role-Based Tiered Pricing System

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.

🔑 3 custom WP user roles woocommerce_get_price hook Retail price gate Per-product meta fields

Tiered price filter — serves role-specific pricing at the WooCommerce data layer:

wholesale-pricing.php
// 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
}
2
Feature 02 — Purchase Rules
MOQ Enforcement

Minimum Order Quantity — Triple-Layer Enforcement

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.

📦 Per-product MOQ meta woocommerce_add_to_cart_validation woocommerce_check_cart_items Checkout server-side guard
3
Feature 03 — Account Access
Buyer Approval

Wholesale Account Application & Approval Workflow

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.

📋 Custom application form Admin approval dashboard Auto role promotion on approval Branded email notifications
4
Feature 04 — Seller Intelligence
ROI Display

Per-Product ROI Margin & FBA Cost Display

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.

📊 Live ROI margin card FBA fee + sale price fields Visible to wholesale only Calculated at render time

How It Works Under the Hood

The entire system is orchestrated through WooCommerce filter and action hooks — no database schema changes, no REST API overrides, no frontend framework dependencies.

01

Visitor arrives — role check runs immediately

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.

02

Approved buyer sees tiered price + ROI card

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.

03

MOQ validation fires at three independent layers

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.

04

New buyer applies — admin reviews and approves in one click

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:

wholesale-approval.php
// 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;
}
05

Admin manages everything from WooCommerce product screens

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:

wholesale-moq.php
// 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;
}

Stack & Approach

Every component relies exclusively on WordPress and WooCommerce core APIs — no third-party packages, no external database tables, and no frontend framework dependencies.

👤

Custom WordPress User Roles

Three wholesale roles registered via add_role() on activation — Silver, Gold, Platinum — each with scoped capabilities and clean removal on plugin deactivation.

🪝

WooCommerce Price Filters

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.

🛡️

Triple-Layer MOQ Validation

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.

📋

Custom Post Type — Applications

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.

🔧

WooCommerce Product Data Tab

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.

📊

Live ROI Calculator (Server-Side)

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.


What the Client Got

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.

🔐

Fully Gated Wholesale Store

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.

📦

Zero MOQ Violations Since Launch

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.

Streamlined Buyer Onboarding

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.

💰

ROI Data Drives Higher Average Order Value

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."

Muhammad Abdullah Hashmi  ·  Full-Stack WordPress, WooCommerce & PHP Developer  ·  8 Years Experience

Available for New Projects

Need a custom B2B platform?

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.