Rule 1: one price, because one calculation
The most common complaint about wholesale plugins is a product listed at one price and charged at another. It happens when the shop page and the cart work the number out separately.
Here there is one calculation, and it answers through woocommerce_product_get_price (and its variation twin) — the one value that the shop loop, the product page, the classic cart, the mini-cart, the Cart and Checkout blocks, the Store API and the order line all read. Change that value once and every surface follows.
The flow for a signed-in customer:
- WooCommerce asks a product for its price.
- The plugin finds the customer's trade role (Rule 2). No trade role: the price is left alone.
- It works out the trade price — in the free edition, the role's percentage off the regular price; in the Full edition, the first of a typed product price, a parent's typed price, a category rate, or the role's percentage.
- It returns that price, rounded to your store's price decimals.
The answer is remembered for the rest of the request, so a page with forty products does not repeat the work.
Regular price, never the sale price
The percentage comes off the regular price. A trade term is not a promotion to stack on a sale; a shop that compounds them sells below cost during every sale it runs.
The sale price is replaced for a trade customer too. Otherwise a product on sale would charge the trade customer the public sale price whenever that happened to be lower. So a trade customer always pays their trade price, sale or not. A product that is not on sale is not made to look like one: its sale price stays empty, so neither a simple nor a variable product shows a "Sale!" badge to a trade customer just because they pay less.
Worked example: regular price 100.00, on sale at 70.00, trade discount 20%.
- The public pays 70.00.
- A trade customer pays 80.00 (20% off 100.00).
If you want trade customers to benefit from a sale, run the sale as a lower regular price, or (Full edition) type a product price.
Variable products
WooCommerce caches a variable product's price range ("From 12.00 to 30.00") against a hash. The plugin adds the customer's trade role to that hash, so the range is cached separately for each role. Without it, the first visitor after the cache was cleared would decide what range everybody else saw.
Rule 2: a customer can hold more than one role
WordPress users have a list of roles. When a retail customer is upgraded to trade, they often keep customer too — and a plugin that reads only their first role charges them retail forever.
The plugin reads every role a user holds:
- Free edition: the customer is a trade customer if any of their roles is
wholesale_customer. - Full edition: the roles in your Who buys at trade prices table are checked in the order you listed them; the first one the customer holds is the one they buy under.
Rule 3: a trade account is granted, never claimed — Full edition
Nothing a visitor submits gives them a trade price.
- Put
[gatemi_wholesale_form]on a page. - A signed-in customer presses Apply for a trade account. They are recorded as having applied (
_gmwh_status=pending), and the site's admin email is told, with a link to the Users screen. Applying twice is one application. - On Users, the Trade column shows Applied.
- Hover the user and click Approve trade account. The plugin adds the first role in your table to the user — their existing roles stay — and marks them approved. The column now shows the role.
- Remove trade account on a trade customer takes every trade role off them and marks them as declined. An account whose only role was the trade one is given the ordinary Customer role, so it is never left with no role at all.
The form shows a different sentence to a visitor who is signed out, a customer who already has a trade account, one whose application is pending, and one who was declined ("Please get in touch with us about a trade account").
Approving needs the promote_users capability. The Approve trade account link is offered on any user without a trade role, not only on applicants.
Trade-only products
A product marked Trade accounts only (_gmwh_only, set in the Full edition product panel) is refused in four places, not merely hidden:
- It is left out of the shop's main product queries.
- WooCommerce is told it is not visible.
- It is not purchasable.
- Adding it to the cart is refused with a notice.
A product id is a guessable number, so hiding it from listings alone would leave it one URL away.
- Full edition: trade customers see and buy these products normally; everybody else is refused.
- Free edition: the free edition cannot mark a product trade-only, but it honours a flag the full edition wrote — and it does so for everybody, trade customers included. A product you held back stays held back rather than appearing on the open web when the full edition is not running.
The list of trade-only ids is cached for an hour (gmwh_only_ids in the full edition, gmwhf_only_ids in the free one). Saving a product in the full edition clears it.
Minimum orders — Full edition
When a trade role has a Minimum order value or Minimum items:
- The cart page shows a notice above the cart, such as "Trade orders start at 250.00. Your basket comes to 180.00, so you need 70.00 more."
- WooCommerce's own cart check adds the same message as an error, which stops the checkout until the cart meets the minimum.
The value is measured at the prices the customer actually pays.
Tax exemption — Full edition
With Tax exempt ticked on a role, the plugin answers WooCommerce's is_vat_exempt question with "yes" for customers buying under that role. WooCommerce then removes tax from their cart and order. Whether a trade customer may lawfully buy without tax is for you and your accountant; the plugin only applies your choice.
What is shown
With Show the retail price struck through on, a trade customer sees retail trade and the badge, using the same <del>/<ins> markup WooCommerce uses for a sale, so your theme already styles it. On a product that is on sale, WooCommerce has already drawn that pair, so only the badge is added. The full edition can also say what they save on the product page.
