Gatemi Order Alerts Developer Reference

WooCommerce hooks used

Hook Edition What the plugin does
woocommerce_email_recipient_new_order (filter, priority 20) Both Appends the whole-order recipients to WooCommerce's list.
woocommerce_order_status_processing or _completed (action) Full Claims the order and sends suppliers their own lines.
woocommerce_low_stock (action) Full Sends low-stock alerts to rules that ask for them.

Because the recipients are appended inside WooCommerce's own filter, another plugin hooking it later (priority above 20) sees the list with Order Alerts' addresses already added.

Filters — Full edition

The free edition applies no filters of its own.

Filter Arguments Use
gmal_settings array $settings The merged settings, after defaults.
gmal_rules array $rules The routing table, as read.
gmal_order_alert array $message, WC_Order $order, array $alert One supplier's message before it is sent. Return false (or an array without to) to cancel it.
gmal_modules array $modules The ordered module list the plugin boots.
gmal_license_api_url string $url The gatemi.com licensing endpoint.
gmal_update_cache_ttl int $seconds How long update information is cached.
gmal_update_retry_ttl int $seconds Wait after a failed update check.
Action Arguments When
gmal_booted Container $container After every module has booted.

$message has the keys to, subject and body. $alert has email (the recipient), labels (the names of the rules that matched) and lines (the WC_Order_Item_Product objects listed).

Examples

Add the customer's phone number to a supplier's message:

add_filter( 'gmal_order_alert', function ( $message, $order, $alert ) {
	$phone = $order->get_shipping_phone() ?: $order->get_billing_phone();
	if ( $phone ) {
		$message['body'] .= "nnPhone: " . $phone;
	}
	return $message;
}, 10, 3 );

Send one supplier their lines through an API instead of email:

add_filter( 'gmal_order_alert', function ( $message, $order, $alert ) {
	if ( 'orders@frozen.example' === $alert['email'] ) {
		my_supplier_api_push( $order->get_order_number(), $alert['lines'] );
		return false; // The order stays claimed.
	}
	return $message;
}, 10, 3 );

Data

Name Type Contents
gmal_settings Option enabled, status, stock_alerts, include_address, order_subject, order_body, stock_subject, stock_body. Shared by both editions.
gmal_rules Option The routing table, keyed by rule id. Shared by both editions.
gmal_license Option Full edition licence state.
gmal_update_payload Transient Full edition cached update information.
gmal_license_check Cron hook Full edition twice-daily licence check, only while a key is entered.
_gmal_sent Order meta Full edition claim: the time (UTC) the supplier messages were sent.

The plugin creates no tables and adds no product or customer meta.

The rule shape

'frozen-supplier' => array(
	'id'         => 'frozen-supplier',
	'label'      => 'Frozen supplier',
	'recipients' => array( 'orders@frozen.example' ),
	'scope'      => 'classes',        // all | products | categories | classes
	'targets'    => array( 'chilled-goods' ), // ids, or class slugs
	'send'       => 'lines',          // lines | order
	'low_stock'  => true,
	'enabled'    => true,
),

When saved or read, a rule is normalized: an unknown scope becomes all, a rule about all is always send => order, a narrowed rule with no send becomes lines, invalid addresses are dropped and duplicates removed. Two rules never share an id (-2 is appended). Writing to gmal_rules with update_option() is supported, but rules are normalized again when read.

Constants

The full edition defines GMAL_VERSION, GMAL_PLUGIN_FILE, GMAL_PLUGIN_DIR, GMAL_PLUGIN_URL and GMAL_BASENAME. The free edition stands down when GMAL_VERSION is defined.

Shopping Cart
Scroll to Top