Names
For a status with slug awaiting-stock:
| Thing | Value |
|---|---|
| WordPress post status | wc-awaiting-stock |
What $order->get_status() returns |
awaiting-stock |
| Bulk action id | mark_awaiting-stock |
| WooCommerce status action | woocommerce_order_status_awaiting-stock |
| Orders-list badge class | .order-status.status-awaiting-stock |
WooCommerce and WordPress hooks used
| Hook | Use |
|---|---|
init |
register_post_status() for each status. |
wc_order_statuses |
Appends each status as wc-{slug} => label. |
bulk_actions-edit-shop_order, bulk_actions-woocommerce_page_wc-orders |
Adds "Change status to …". |
handle_bulk_actions-edit-shop_order, handle_bulk_actions-woocommerce_page_wc-orders |
Applies it with update_status(); adds gmos-changed={count} to the redirect. |
admin_enqueue_scripts |
Full edition: inline badge colours (style handle gmos-status-colors). |
woocommerce_order_status_changed |
Full edition: sends the status email. |
Filters — Full edition
The free edition applies no filters of its own.
| Filter | Arguments | Use |
|---|---|---|
gmos_statuses |
array $statuses |
The sanitized status list, before use — registration, dropdowns, bulk actions, colours and emails all read it. |
gmos_email |
array $email, WC_Order $order, array $status |
The message as to, subject, body. Return an empty to to cancel. |
gmos_modules |
array $modules |
The ordered module list. |
gmos_license_api_url |
string $url |
The gatemi.com licensing endpoint. |
gmos_update_cache_ttl |
int $seconds |
How long update information is cached. |
| Action | Arguments | When |
|---|---|---|
gmos_booted |
Container $container |
After every module has booted. |
Examples
React when an order enters a custom status (works with either edition — it is WooCommerce's own action):
add_action( 'woocommerce_order_status_ready-to-deliver', function ( $order_id, $order ) {
my_courier_book_collection( $order );
}, 10, 2 );
Add a status from code, without the screen (full edition):
add_filter( 'gmos_statuses', function ( $statuses ) {
$statuses[] = array(
'slug' => 'quality-check',
'label' => 'Quality check',
'color' => '#7c3aed',
'email_enabled' => 'no',
'email_subject' => '',
'email_body' => '',
);
return $statuses;
} );
A status added this way is not stored, so it is not on the settings screen, and it disappears if the filter is removed.
Add a line to the status email (full edition). The body is already HTML — paragraphs made by wpautop(), sent with Content-Type: text/html — so add markup, not plain text:
add_filter( 'gmos_email', function ( $email, $order, $status ) {
$email['body'] .= '<p>Questions? Reply to this email.</p>';
return $email;
}, 10, 3 );
Find orders in a custom status:
$orders = wc_get_orders( array( 'status' => 'awaiting-stock', 'limit' => -1 ) );
Data
| Name | Type | Contents |
|---|---|---|
gmos_statuses |
Option | The list of statuses, shared by both editions. |
gmos_license |
Option | Full edition licence state. |
gmos_update_payload |
Transient | Full edition cached update information. |
gmos_license_check |
Cron hook | Full edition licence check, only while a key is entered. |
A row in gmos_statuses:
array(
'slug' => 'awaiting-stock', // a-z 0-9 - _, max 17 characters
'label' => 'Awaiting stock',
'color' => '#f59e0b', // full edition; default #777777
'email_enabled' => 'yes', // full edition
'email_subject' => '', // full edition
'email_body' => '', // full edition
)
The free edition reads only slug and label, shows the first three rows, and when it saves keeps the other keys on a row whose slug it kept and every row after the third. The plugin creates no tables and no order meta.
On the settings screen a saved row posts its slug as a hidden original field instead of an editable slug, and the sanitizer keeps a stored original over any posted slug — in both editions — so a status's slug never changes once saved.
Constants
The full edition defines GMOS_VERSION, GMOS_PLUGIN_FILE, GMOS_PLUGIN_DIR, GMOS_PLUGIN_URL and GMOS_BASENAME. The free edition stands down when GMOS_VERSION is defined.
