Skip to main content

WooCommerce Product Update Webhook

The middleware exposes an inbound webhook endpoint that WooCommerce triggers whenever a product is updated. This keeps the local products table in sync with both the Retail and Dealers WooCommerce stores.


Endpoint

POST /api/webhook/woocommerce-product-update

Purpose

The local products table drives the sale-price overlay feature. When a product's markup_sale_price, sale_starts_at, or sale_ends_at fields change in WooCommerce, the webhook ensures the middleware reflects those changes before the next nFusion sync run.


Configuration

Environment Variable

RETAIL_WEBHOOK_SECRET=your_woocommerce_webhook_secret

This secret must match the Secret field in WooCommerce webhook settings and is used to verify the HMAC-SHA256 x-wc-webhook-signature header.


Setting Up the Webhook in WooCommerce

  1. Log in to the WooCommerce admin.
  2. Go to WooCommerce → Settings → Advanced → Webhooks.
  3. Click Add webhook and configure:
FieldValue
NameCertiLock — Product Update
StatusActive
TopicProduct Updated
Delivery URLhttps://dash.scottsdalemint.com/api/webhook/woocommerce-product-update
SecretValue of RETAIL_WEBHOOK_SECRET
  1. Save. WooCommerce will fire this webhook on every product.updated event.

Validation

The WooCommerceProductUpdateController performs two checks before processing:

  1. Signature verification — computes HMAC-SHA256(rawBody, secret) and compares it to the x-wc-webhook-signature header.
  2. Topic check — verifies x-wc-webhook-resource is product and x-wc-webhook-topic is product.updated.

Any validation failure returns a 401 or 400 response. A valid request returns 200.


Payload

WooCommerce sends the full product object. The controller extracts:

WooCommerce FieldLocal Column
skusku (used as the unique key)
Any product fieldsStored / updated in products table

Local Testing with ngrok

# 1. Expose local app
ngrok http --host-header=rewrite certilock-storage.test:443

# 2. In WooCommerce, set the delivery URL to your ngrok tunnel:
# https://xxxx.ngrok-free.app/api/webhook/woocommerce-product-update

# 3. Save a product in WooCommerce — the webhook will fire

Key File

app/Http/Controllers/Webhook/WooCommerceProductUpdateController.php