Gatemi Discount Rules Developer Reference

The free edition applies no filters or actions of its own. Everything under Filters and Actions is the full edition's.

Filters — Full edition

gmdr_condition_types

The condition vocabulary. Each entry is keyed by its id and has a label, a value kind (number, list, text or date) and a list of compares drawn from gte, lte, equals, in, not_in. The rule builder lists your type and the rule storage accepts it. An entry with no compares is dropped.

gmdr_evaluate_condition

The verdict on a condition type the plugin does not know.

Argument Type
$verdict bool false
$condition array type, compare, value
$rule GatemiDiscountRulesRulesRule The rule
$context GatemiDiscountRulesRulesContext The cart: lines(), subtotal(), quantity(), product_ids(), category_ids(), roles(), is_logged_in(), today()

The default is false, so a condition nobody answers keeps the rule from applying rather than applying it to everybody.

// A condition: the shipping country is one of a list.
add_filter( 'gmdr_condition_types', function ( $types ) {
	$types['ship_country'] = array(
		'label'    => 'Shipping country',
		'value'    => 'list',
		'compares' => array( 'in', 'not_in' ),
	);
	return $types;
} );

add_filter( 'gmdr_evaluate_condition', function ( $verdict, $condition ) {
	if ( 'ship_country' !== $condition['type'] || ! WC()->customer ) {
		return $verdict;
	}
	$hit = in_array( WC()->customer->get_shipping_country(), (array) $condition['value'], true );
	return 'in' === $condition['compare'] ? $hit : ! $hit;
}, 10, 2 );

Remove such a filter and its type stops being in the vocabulary. A condition of a type that is no longer declared is kept on the rule when it is read and saved, shown in the editor as "not recognised", and evaluates to false — so the rule is held back rather than widened to everybody. Put the code back and the condition works again.

A list value typed as 12, 14 is stored as an array (split on commas and new lines), and the evaluator also splits a legacy string, so in and not_in compare against each value.

gmdr_rules

The list of Rule objects after they are read and normalised. Return only Rule instances; anything else is dropped.

gmdr_settings

The display settings (catalog_prices, tier_table, cart_badges, savings_line), merged over the defaults.

Others

Filter What it changes
gmdr_modules The module list the plugin boots
gmdr_license_api_url The licence API base, default https://gatemi.com/wp-json/gatemi-license/v1
gmdr_update_cache_ttl How long an update answer is cached (default 12 hours)
gmdr_update_retry_ttl How long to wait after a failed update check (default 15 minutes)
gmdr_sync_cache_ttl How long a shared licence roster is cached

Actions — Full edition

gmdr_booted fires once all modules are wired, with the service container.

The rule option: gmdr_rules

Shared by both editions. A list of arrays:

array(
	'id'         => 'summer-sale',
	'title'      => 'Summer sale',
	'enabled'    => 'yes',
	'type'       => 'product',   // product | tiered | cart | bogo
	'discount'   => 'percent',   // percent | fixed | fixed_price
	'amount'     => 15.0,
	'tiers'      => array( array( 'quantity' => 5, 'discount' => 'percent', 'amount' => 10.0 ) ),
	'bogo_buy'   => 1,
	'bogo_get'   => 1,
	'applies_to' => 'categories', // all | products | categories
	'products'   => array(),
	'categories' => array( 12 ),
	'conditions' => array( array( 'type' => 'date_to', 'compare' => 'lte', 'value' => '2026-08-31' ) ),
	'stop'       => 'yes',
	'label'      => 'Summer sale',
)

The free edition reads only rules of exactly this form: type tiered, applies_to products with one product id, enabled yes, no conditions, no categories, one to three tiers each percent or fixed. Its own rules have the id gmdrf-<product id>. Every other rule is kept on save and not priced.

Cart item keys

Edition Keys
Free gmdrf_base (the stored price), gmdrf_discount (base, price, label)
Full gmdr_base, gmdr_discount (rule, label, base, price)

Order item meta — Full edition

_gmdr_rule, _gmdr_base, _gmdr_label on each discounted line, written on woocommerce_checkout_create_order_line_item. The free edition writes no order meta; the discounted price is the line's own price.

Hooks the plugin listens on

Hook Priority What happens
woocommerce_before_calculate_totals 20 Line prices
woocommerce_cart_calculate_fees 20 Cart and buy-one-get-one fees (full)
woocommerce_get_price_html 20 Catalog price and note
woocommerce_single_product_summary 25 The tier table
woocommerce_cart_item_name 20 The line badge
woocommerce_cart_totals_before_order_total 10 You saved (full)

The free edition registers its storefront hooks only outside wp-admin.

CSS classes

Class Edition Element
.gmdrf-tiers, .gmdr-tiers free, full The "Buy more, pay less" table
.gmdrf-badge, .gmdr-badge free, full The badge on a cart line (full: also on the catalog price)
.gmdrf-from free The "5+ from … each" note after the price
.gmdr-price full The struck-through and new price together
.gmdr-savings full The You saved totals row

Stylesheet handles: gmdrf (free) and gmdr (full).

Shopping Cart
Scroll to Top