Gatemi Sequential Order Numbers Developer Reference

The free edition applies no filters of its own. The hooks below are the full edition's; the storage is shared by both.

WooCommerce hooks used

Hook Kind What the plugin does
woocommerce_new_order action, priority 10 Draws and stores the number
woocommerce_order_number filter, priority 10 Returns the stored _gmson_formatted value, or WooCommerce's own number when there is none

To read the number in your own code, use WooCommerce's $order->get_order_number(); it already passes through the filter.

Filters — Full edition

gmson_formatted_number

The number as it will be shown, at the moment it is assigned and frozen. Whatever you return is stored on the order and never worked out again.

Argument Type
$formatted string Prefix + padded number + suffix, date variables filled in
$raw int The raw sequence number
// Add the store's branch code to every new order number.
add_filter( 'gmson_formatted_number', function ( $formatted, $raw ) {
	return 'LDN-' . $formatted;
}, 10, 2 );

gmson_settings

The settings merged with their defaults (enabled, start, prefix, suffix, padding), before use.

gmson_modules, gmson_license_api_url, gmson_update_cache_ttl

The boot module list, the gatemi.com licence API base URL (for staging) and how long the update check is cached, in seconds.

Actions — Full edition

gmson_booted

Fires once the plugin has booted, with its service container.

Storage

Options

Option Edition
gmson_counter both The last number drawn. Not autoloaded. Shared, so the sequence carries over between editions
gmsonf_settings free enabled, start
gmson_settings full enabled, start, prefix, suffix, padding
gmson_license full Licence state

The counter is advanced with one SQL statement:

UPDATE wp_options
SET option_value = LAST_INSERT_ID(GREATEST(CAST(option_value AS UNSIGNED) + 1, <start>))
WHERE option_name = 'gmson_counter'

and the drawn value is read back with SELECT LAST_INSERT_ID() on the same connection. Do not change gmson_counter with update_option() on a live shop: the plugin bypasses the option cache to move it, and a cached write can hand out a number twice. Raise Start counting at instead.

On MySQL and MariaDB the number is the counter's. The SQLite integration used by WordPress Playground has no LAST_INSERT_ID() function, so there the counter does not move and numbers come from a fallback; do not rely on the start number on SQLite.

Order meta

Key
_gmson_number The raw sequence number, as a string
_gmson_formatted The number as shown (free edition: the same as _gmson_number)

Written through the order's meta API, so they work under HPOS and the legacy order store. To find an order by its number:

$orders = wc_get_orders( array(
	'limit'      => 1,
	'meta_key'   => '_gmson_formatted',
	'meta_value' => '2026-00042',
) );

Admin

WooCommerce → Order Numbers, capability manage_woocommerce.

Shopping Cart
Scroll to Top