The free edition applies no filters of its own. Everything under Filters and Actions is the full edition's.
Filters — Full edition
gmwh_price
A resolved trade price, before it is used. Runs once per product and role per request (the result is remembered). Return null to charge the ordinary price.
| Argument | Type | |
|---|---|---|
$price |
float|null |
The resolved price, or null when no rule applied |
$product |
WC_Product |
The product or variation |
$role |
string |
The trade role the customer buys under |
A returned number below 0 is raised to 0.
// Trade price never below 60% of the regular price.
add_filter( 'gmwh_price', function ( $price, $product, $role ) {
$regular = (float) $product->get_regular_price( 'edit' );
return null === $price ? null : max( $price, $regular * 0.6 );
}, 10, 3 );
gmwh_roles
Which roles count as trade roles, in priority order. Default: the roles in the settings table, or array( 'wholesale_customer' ) when the table is empty.
gmwh_role_for_user
The trade role a user buys under, after the multi-role check. '' means not a trade customer.
| Argument | Type | |
|---|---|---|
$role |
string |
The role found, or '' |
$user_id |
int |
The user |
// Treat users with a "net30" account flag as trade even without the role.
add_filter( 'gmwh_role_for_user', function ( $role, $user_id ) {
return '' === $role && get_user_meta( $user_id, 'net30', true ) ? 'wholesale_customer' : $role;
}, 10, 2 );
gmwh_settings
The merged settings array after defaults: roles, category_rates, show_retail, show_saving, badge.
Other filters
| Filter | What it tunes |
|---|---|
gmwh_modules |
The ordered module list the plugin boots |
gmwh_license_api_url |
The gatemi.com licensing endpoint |
gmwh_update_cache_ttl |
How long the update payload is cached, in seconds |
gmwh_update_retry_ttl |
How long a failed update check waits before retrying |
gmwh_sync_cache_ttl |
How long the licence sync result is cached |
Actions — Full edition
| Action | Arguments | When |
|---|---|---|
gmwh_approved |
$user_id, $role |
A trade account was approved and the role added |
gmwh_booted |
$container |
After every module has booted |
// Email the customer when their trade account is approved.
add_action( 'gmwh_approved', function ( $user_id, $role ) {
$user = get_userdata( $user_id );
wp_mail( $user->user_email, 'Your trade account is ready', 'Sign in to see your trade prices.' );
}, 10, 2 );
WooCommerce hooks used (both editions)
| Hook | Priority | Purpose |
|---|---|---|
woocommerce_product_get_price, woocommerce_product_variation_get_price |
20 | The trade price |
woocommerce_product_get_sale_price, woocommerce_product_variation_get_sale_price |
20 | Replaces a sale price with the trade price |
woocommerce_variation_prices_price, woocommerce_variation_prices_sale_price |
20 | Variable product price ranges |
woocommerce_get_variation_prices_hash |
20 | Adds gmwh:{role} to the range cache hash |
woocommerce_is_purchasable, woocommerce_product_is_visible, woocommerce_add_to_cart_validation, pre_get_posts |
20 / 10 | Trade-only products |
woocommerce_get_price_html |
20 | Struck-through retail price and badge |
woocommerce_check_cart_items |
10 | Full: minimum order errors |
woocommerce_before_cart |
10 | Full: minimum order notice |
woocommerce_customer_get_is_vat_exempt |
20 | Full: per-role tax exemption |
woocommerce_single_product_summary |
11 | Full: the "saves you" line |
To act after the trade price, hook woocommerce_product_get_price at a priority above 20.
Shortcode — Full edition
[gatemi_wholesale_form] — the trade-account application form. No attributes. Posts to the same page with the field gmwh_apply and a nonce.
Options
| Option | Edition | Holds |
|---|---|---|
gmwh_settings |
Both | roles, category_rates, show_retail, show_saving, badge |
gmwh_license |
Full | Licence state |
roles is a list of rows:
array(
'role' => 'wholesale_customer',
'percentage' => '20',
'min_amount' => '250',
'min_quantity' => '0',
'tax_exempt' => 'no',
)
category_rates rows are role, category (term id) and percentage. The free edition reads only the wholesale_customer row's percentage, plus show_retail and badge, and writes the rest back untouched.
Transients: gmwh_only_ids (full) and gmwhf_only_ids (free), the cached trade-only product ids, one hour. gmwh_update_payload and the cron event gmwh_license_check belong to the full edition's licence client.
Post and user meta
| Key | On | Value | Edition |
|---|---|---|---|
_gmwh_prices |
Product / variation | array( role => price ) |
Written by full, read by full |
_gmwh_only |
Product | yes / no |
Written by full, read by both |
_gmwh_status |
User | pending, approved, rejected |
Full |
The role
wholesale_customer, label Wholesale customer, created on activation by either edition as a copy of customer's capabilities (or just read if customer is missing). It is never removed by the plugin.
CSS classes
The storefront stylesheet loads only for trade customers.
| Class | Element |
|---|---|
.gmwh-price |
Wrapper around the struck-through and trade price |
.gmwh-badge |
The badge |
.gmwh-saving |
Full: the "saves you" line |
.gmwh-minimum |
Full: the minimum-order notice on the cart |
.gmwh-form, .gmwh-form-note, .gmwh-form-button |
Full: the application form |
Constants
| Constant | Edition |
|---|---|
GMWHF_VERSION, GMWHF_PLUGIN_URL |
Free |
GMWH_VERSION, GMWH_PLUGIN_URL |
Full |
The free edition stands down whenever GMWH_VERSION is defined.
