Skip to main content

WooCommerce

WooCommerce is the shop plugin for WordPress. Its webhooks call an address when an order is created and every time it is updated. Pointed at the Flows address, they start your flows: an order is placed, paid, completed or cancelled — and the customer gets the right message in Viber or SMS, with a reminder if the payment does not come.

Written from WooCommerce documentation

This page is written from the public documentation of WooCommerce and has not been checked on a live account yet.

What you need​

  • WooCommerce itself is free: it is a WordPress plugin on your own hosting. Webhooks are part of it, in WooCommerce → Settings → Advanced → Webhooks, and you need access to these settings.
  • Two webhooks — Order created and Order updated — with the same address. The type of the event travels in a header of the request, so one address serves both.

Step 1. Create a connection​

  1. Open Flows → Connections, press Connect a system and choose WooCommerce.
  2. Press Copy address. It looks like https://events.alphasms.net/hooks/<TOKEN> — keep it secret.

Step 2. Set up webhooks in WooCommerce​

  1. Open WooCommerce → Settings → Advanced → Webhooks and press Add webhook.
  2. Name — what the webhook sends, for example "AlphaFlow — order created".
  3. Status — Active.
  4. Topic — Order created.
  5. Delivery URL — the address from the cabinet.
  6. Secret — leave it as it is (see Good to know).
  7. API Version — WP REST API Integration v3. The field is in the form, but the WooCommerce documentation does not name its values, so this choice is not confirmed by the documentation.
  8. Press Save webhook.
  9. Add the second webhook the same way: Name "AlphaFlow — order updated", Topic — Order updated, the same Delivery URL.

Do not use the topics of the Action type: they send only the name of an action and its argument, without a phone.

Step 3. Send a test​

When you save a webhook with the status Active for the first time, WooCommerce sends a ping to the Delivery URL. AlphaFlow accepts it and records nothing — no event and no refusal. Then place a test order with your own phone number. The event appears in Flows → Connections → Event journal, and the connection shows Recognised: WooCommerce. WooCommerce keeps its own log of deliveries in WooCommerce → Status → Logs, source webhooks-delivery.

Events​

WooCommerce webhookAlphaFlow eventProperties
Order createdorder_createdorder_id, total, status
Order updated, status processing with a payment date (date_paid)order_paidorder_id, total, status
Order updated, status processing without a payment dateorder_status_changedorder_id, status
Order updated, status completedorder_deliveredorder_id, total, status
Order updated, status cancelledorder_cancelledorder_id, total, status
Order updated, status refundedrefund_issuedorder_id, total, status
Order updated, status failedpayment_failedorder_id, total, status
Order updated, any other statusorder_status_changedorder_id, total, status

Every event also carries currency, payment_method (the name of the payment method), first_name, last_name and city (the city of delivery).

  • processing becomes order_paid only when the order has a payment date (date_paid): an order paid on delivery also goes to processing, but unpaid, and comes as order_status_changed. In WooCommerce completed means that the order is fulfilled.
  • The statuses are matched by a table that you can correct in the connection. Statuses added by plugins (for example, a "shipped" status of a delivery plugin) come as they are — add them to the table, for example as order_shipped.
  • WooCommerce itself has no tracking number: delivery plugins keep it in their own fields, which the connection does not read.

The contact is found by the phone and the email of the billing address (billing.phone, billing.email) and by the WooCommerce id of the customer (customer_id). For a guest order WooCommerce sends 0 instead of the id, so such an order is matched by the phone and the email. The time of the event is the time the order was last modified (date_modified_gmt, in UTC). The names of the events are the ones the ready-made templates expect — see Recommended events.

Good to know​

  • WooCommerce delivers a webhook once, in the background (through wp-cron), and does not repeat it. An answer other than 2xx, 301 or 302 counts as a failure; after more than five failures in a row WooCommerce disables the webhook (Status: Disabled), and it has to be switched on again by hand.
  • Order updated comes on any edit of an order, not only on a change of its status, and carries the current status. AlphaFlow records it once per status of the order: an edit that does not change the status is not a new event.
  • WooCommerce signs every request with the Secret (the header X-WC-Webhook-Signature). The signature is optional: the secret in the address is enough, and AlphaFlow checks the signature only if you copy the secret into the connection.
  • The address always answers 200. Above the daily event limit the event is refused in AlphaFlow with quota_exceeded and shown in the journal; the webhook in WooCommerce stays on.

WooCommerce documentation​