How Gatemi Store Events Works

Four rules govern the plugin, and both editions keep all four.

Rule 1: one catalogue of events

Every event is declared once, as data: a key, a label, the WooCommerce hook it listens to and what it is about (an order, a product, a customer or a review). The settings screen draws its checkboxes from that list, the saved channels are checked against it, the hooks are attached from it, and each event has exactly one message. Nothing is wired by hand in a second place.

Event WooCommerce hook Edition
A new order woocommerce_checkout_order_processed and woocommerce_store_api_checkout_order_processed Both
An order changing status woocommerce_order_status_changed Full
An order cancelled woocommerce_order_status_cancelled Full
An order refunded woocommerce_order_status_refunded Full
A product running low woocommerce_low_stock Full
A product out of stock woocommerce_no_stock Full
A new customer account woocommerce_created_customer Full
A new product review comment_post (product reviews only) Full

The free edition attaches the new-order hooks and nothing else.

woocommerce_checkout_order_processed is fired by WooCommerce's classic (shortcode) checkout, woocommerce_store_api_checkout_order_processed by the Checkout block. Orders created in wp-admin or through the REST API fire neither, so they are not announced as new orders. In the full edition, an order changing status subscription still reports them when their status moves.

Rule 2: nothing is posted from the request that caused it

The obvious way to build this posts to Slack inside the checkout — and then Slack having a slow afternoon is your checkout having a slow afternoon, and an unreachable channel is an error in the middle of an order. Here:

  1. The event fires (an order is placed).
  2. If the master switch is off, or no active channel with a usable destination subscribes to this event, nothing happens at all — no order is even read.
  3. The one-line message is built.
  4. The gmsef_announce / gmse_announce filter may hold it back.
  5. The event is claimed (rule 3).
  6. One message per subscribed channel is added to the queue — an option, gmsef_outbox (free) or gmse_outbox (full).
  7. A single cron event (gmsef_flush / gmse_flush) is scheduled for right now. WordPress runs it in a separate request.

That separate request posts the queued messages. While anything is waiting, a sweep (gmsef_sweep / gmse_sweep) also runs every five minutes, for the quiet shop where nothing triggers cron for an hour. When the queue is empty the sweep is unscheduled.

A message the channel refuses (Slack answers HTTP 429 on a busy morning) stays in the queue and is retried. After three failed tries it is dropped. The queue is capped (50 free, 200 full), because an option that grows without limit eventually cannot be read.

Rule 3: one order is one message

WooCommerce fires order hooks more than once in ordinary operation. Before anything is queued, the event's key is written into the order's _gmse_posted meta and the order is saved. If the key is already there, nothing is queued. So "New order #1481" never arrives twice.

In the full edition a status change is claimed per status (order_status:completed), so an order that goes to Processing and then Completed is reported once for each.

Both editions use the same _gmse_posted key. An order the full edition already announced is never announced again by the free edition, and the other way round.

Product, customer and review events have no order to claim on. A message that is already waiting in the queue for the same thing and channel is not added twice.

Rule 4: only two hosts, ever

The plugin posts to exactly two hosts: hooks.slack.com for Slack and api.telegram.org for Telegram. The host must match exactly — a lookalike such as hooks.slack.com.evil.example is refused — and the address must be https. This is checked:

  • when you save the channel,
  • when the channel is read back, and
  • immediately before each request is sent.

The last check is the one a future change is most likely to route around, which is why it is there. Without this rule, a plugin whose whole job is to send order details somewhere would be one configuration change away from sending them anywhere.

If the channel's reply contains the webhook URL or the bot token, they are replaced with [redacted] before anything is shown or logged — a Slack webhook URL is the credential.

What a message contains

One line of plain text — Slack and Telegram format text differently, and plain text reads the same in both:

  1. Your prefix, if you set one.
  2. What happened and the order number: New order #1234.
  3. The total, as the store's currency code and the amount with the store's own number of decimals (WooCommerce → Settings → General): GBP 25.00, JPY 4200. It is written by hand rather than with WooCommerce's price formatting, which returns HTML a channel would show literally.
  4. · Jane Smith, when Include the customer's name is on.
  5. The order's admin link, when Include a link back to the order is on.

The customer's email address is never included.

Full edition: stock messages give the product name, SKU and units left; review messages the product, the star rating and "awaiting approval" when the review is held for moderation; customer messages the customer's display name.

Shopping Cart
Scroll to Top