Gatemi Order Bumps Developer Reference

WooCommerce hooks used

Hook Edition Use
woocommerce_review_order_before_submit Both Prints offers placed "Just above the pay button".
woocommerce_checkout_before_order_review_heading Full "Above the order summary".
woocommerce_checkout_after_order_review Full "Below the order summary".
woocommerce_cart_totals_before_order_total Full "On the cart page".
woocommerce_checkout_update_order_review Both Reads the posted gmob_bumps[] and accepts or removes offers.
wp_loaded (priority 20) Both Handles the gmob_accept / gmob_decline links.
woocommerce_before_calculate_totals (priority 20) Both Sets the offer price on accepted lines.
woocommerce_get_cart_item_from_session Both Keeps the gmob_bump marker across requests.
woocommerce_get_item_data Both Adds the "Added as" line in the cart.
woocommerce_checkout_create_order_line_item Both Writes _gmob_bump onto the order line.

Filters — Full edition

The free edition applies no filters of its own.

Filter Arguments Use
gmob_settings array $settings The merged settings, after defaults.
gmob_bumps array $bumps The offers, as read and normalized.
gmob_offered bool $offered Whether offers are shown at all on this request.
gmob_condition_types array $types The condition vocabulary: type => array( 'label', 'hint' ).
gmob_evaluate_condition bool $result, array $condition, BumpContext $context Whether one condition matches. Answer here for a type you added.
gmob_modules array $modules The ordered module list.
gmob_license_api_url string $url The gatemi.com licensing endpoint.
gmob_update_cache_ttl int $seconds How long update information is cached.
Action Arguments When
gmob_booted Container $container After every module has booted.

BumpContext (GatemiOrderBumpsBumpsBumpContext) gives you total() (the displayed cart subtotal), item_count() (total quantity), product_ids() (product and variation ids in the cart), holds( $id ) and category_ids() (with ancestors).

A condition type the plugin does not recognise evaluates to false unless your gmob_evaluate_condition callback answers true. A condition whose type is not in gmob_condition_types when the offers are read is kept on the offer (the editor shows it as not recognised) and evaluates to false, so an offer narrowed by a removed extension is held back rather than shown to everybody.

Example: a custom condition

Offer a bump only to logged-in customers:

add_filter( 'gmob_condition_types', function ( $types ) {
	$types['logged_in'] = array(
		'label' => 'The shopper is signed in',
		'hint'  => 'Nothing to type.',
	);
	return $types;
} );

add_filter( 'gmob_evaluate_condition', function ( $result, $condition, $context ) {
	if ( 'logged_in' === $condition['type'] ) {
		return is_user_logged_in();
	}
	return $result;
}, 10, 3 );

Turn offers off for one country:

add_filter( 'gmob_offered', function ( $offered ) {
	return $offered && WC()->customer && 'US' !== WC()->customer->get_shipping_country();
} );

Data

Name Type Contents
gmob_settings Option enabled, max_shown. Shared by both editions.
gmob_bumps Option The list of offers. Shared by both editions.
gmob_license Option Full edition licence state.
gmob_update_payload Transient Full edition cached update information.
gmob_license_check Cron hook Full edition licence check, only while a key is entered.
gmob_bump Cart item key The id of the offer a line came from.
gmob_base Cart item key The price the line came in at.
_gmob_bump Order item meta The offer's heading (or id).

The plugin creates no tables.

The offer shape

array(
	'id'            => 'bump-3f9a1c2e',
	'enabled'       => 'yes',
	'product_id'    => 318,
	'heading'       => 'Add a matching case',
	'description'   => 'Fits every model.',
	'discount_kind' => 'amount',      // none | amount | percent (full edition)
	'discount'      => 5.0,
	'placement'     => 'before_pay',  // before_review | after_review | before_pay | cart
	'conditions'    => array(
		array( 'type' => 'has_category', 'value' => '42' ),
	),
)

Query args

?gmob_accept=<id>&_wpnonce=… and ?gmob_decline=<id>&_wpnonce=…, nonce action gmob_bump. The checkout posts the tick boxes as gmob_bumps[], and each drawn box also posts a hidden gmob_shown[] with its offer id; only an offer named in gmob_shown[] and missing from gmob_bumps[] is declined.

Hooks the plugin uses

  • woocommerce_checkout_update_order_review — the tick, on the checkout's own refresh.
  • woocommerce_checkout_process — a tick posted with Place order; if it changes the cart the order is held back with a notice and refresh_totals.
  • render_block_woocommerce/checkout (both editions) and render_block_woocommerce/cart (full edition) — the offers printed above the block as links.

CSS classes

Class Element
.gmob-bump The offer box.
.gmob-bump--accepted The box when its offer is in the cart.
.gmob-bump-toggle The tick box label (or the cart-page link).
.gmob-bump-heading The heading.
.gmob-bump-text The line about it.
.gmob-bump-price The price, with <del> and <ins> when discounted.

The stylesheet handle is gmob, enqueued only on a page that showed an offer.

Constants

The full edition defines GMOB_VERSION, GMOB_PLUGIN_FILE, GMOB_PLUGIN_DIR, GMOB_PLUGIN_URL and GMOB_BASENAME. The free edition stands down when GMOB_VERSION is defined.

Shopping Cart
Scroll to Top