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
- Log in to the WooCommerce admin.
- Go to WooCommerce → Settings → Advanced → Webhooks.
- Click Add webhook and configure:
| Field | Value |
|---|---|
| Name | CertiLock — Product Update |
| Status | Active |
| Topic | Product Updated |
| Delivery URL | https://dash.scottsdalemint.com/api/webhook/woocommerce-product-update |
| Secret | Value of RETAIL_WEBHOOK_SECRET |
- Save. WooCommerce will fire this webhook on every
product.updatedevent.
Validation
The WooCommerceProductUpdateController performs two checks before processing:
- Signature verification — computes
HMAC-SHA256(rawBody, secret)and compares it to thex-wc-webhook-signatureheader. - Topic check — verifies
x-wc-webhook-resourceisproductandx-wc-webhook-topicisproduct.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 Field | Local Column |
|---|---|
sku | sku (used as the unique key) |
| Any product fields | Stored / 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