Gatemi Cart Notices Developer Reference

The free edition applies no filters or actions of its own. The filters, actions and the shortcode below are the full edition's. The storage is shared.

Filters — Full edition

gmcn_condition_types

apply_filters( 'gmcn_condition_types', array $types ) — the condition vocabulary, type => array( 'label' => …, 'value' => … ) where value is the hint shown beside the value box (empty for none). The editor renders its dropdown from this list, so a type added here appears on the screen.

gmcn_evaluate_condition

apply_filters( 'gmcn_evaluate_condition', bool $result, array $condition, CartContext $context ) — runs for every condition after the built-in answer. For a type the plugin does not know, $result is false; answer for your own type here. $condition is array( 'type' => …, 'value' => … ).

CartContext offers total(), item_count(), product_ids(), category_ids(), roles(), free_shipping_remaining() and minutes_into_store_day().

gmcn_placeholders

apply_filters( 'gmcn_placeholders', array $values, CartContext $context ) — placeholder => replacement for one request. Add your own.

gmcn_notices

apply_filters( 'gmcn_notices', array $notices ) — the notices as read and normalized, before evaluation.

gmcn_settings, gmcn_modules, gmcn_license_api_url, gmcn_update_cache_ttl

The merged settings, the booted module list, the licensing endpoint and the update cache lifetime.

Actions — Full edition

  • gmcn_booted — do_action( 'gmcn_booted', Container $container ).

Example: a "first order" condition

// Full edition only.
add_filter( 'gmcn_condition_types', function ( $types ) {
	$types['first_order'] = array(
		'label' => 'The shopper has never ordered before',
		'value' => '',
	);
	return $types;
} );

add_filter( 'gmcn_evaluate_condition', function ( $result, $condition, $context ) {
	if ( 'first_order' !== $condition['type'] ) {
		return $result;
	}
	if ( ! is_user_logged_in() ) {
		return true;
	}
	return 0 === wc_get_customer_order_count( get_current_user_id() );
}, 10, 3 );

Shortcode — Full edition

[gatemi_cart_notices]
[gatemi_cart_notices placement="checkout"]

Prints the notices that apply for that placement (cart, checkout or minicart; default cart).

Storage

What Where
Master switch option gmcn_settings → enabled (yes/no)
Notices option gmcn_notices — a list
Licence (full) option gmcn_license, transient gmcn_update_payload, cron gmcn_license_check

One notice:

array(
	'name'       => 'Free shipping nudge',
	'message'    => 'Add {remaining} more for free shipping.',
	'placements' => array( 'cart', 'checkout' ), // and 'minicart' (full)
	'style'      => 'notice',                     // 'success', 'error' (full)
	'conditions' => array(
		array( 'type' => 'free_shipping_short', 'value' => '' ),
	),
	'enabled'    => 'yes',
)

No tables, no post meta, no order meta.

WooCommerce hooks used

Hook Placement
woocommerce_before_cart Cart (classic)
woocommerce_before_checkout_form Checkout (classic)
render_block_woocommerce/cart Cart block — appended after it
render_block_woocommerce/checkout Checkout block — appended after it
woocommerce_before_mini_cart_contents Mini-cart — Full edition

Notices are rendered with wc_print_notice( $message, $style, array(), true ). To move them, remove the plugin's callback from these hooks and print through the full edition's shortcode where you want them.

Next

Shopping Cart
Scroll to Top