Using Webhooks

What are Webhooks? ↑ Back to top

 

A Webhook is an event notification sent to a URL of your choice. Users can configure them to trigger events on one site to invoke behavior on another.

Webhooks are useful for integrating with third-party services and other external API that support them.

Webhooks in WooCommerce ↑ Back to top

Webhooks were introduced in WooCommerce 2.2 and can trigger events each time you add, edit or delete orders, products, coupons or customers.

It’s also possible to use Webhooks with WooCommerce actions, e.g., create a webhook to be used every time a product is added to the shopping cart using the action woocommerce_add_to_cart.

Webhooks make it easier for third party apps to integrate with WooCommerce.

Creating, editing and deleting Webhooks ↑ Back to top

Creating Webhooks ↑ Back to top

woocommerce webhooks

To create a new webhook:

  1. Go toWooCommerce > Settings > API > Webhooks.
  2. Click Add
  3. Enter your Settings.

webhook data

  • Name: By clicking on the button webhook is initially created with the name as “Webhook created on [date and time of creation]” this is a standard to facilitate the creation, however you can change the name to something else.
  • Status: Here you can set the Webhooks status, the options are “Active” (delivers payload), “Paused” (does not deliver), or “Disabled” (does not deliver due delivery failures).
  • Topic: Here you can indicate when the webhook will be triggered, we have several options like “Order Created“, “Product Deleted” and “Customer Updated” and we also have the “Action” and “Custom” options.
    • Action Event: This option is available when the Topic is selected as “Action”, should type here one WooCommerce action name, such as woocommerce_add_to_cart for when customers add products to the shopping cart.
    • Custom Topic: Here you can create a custom topic, this option is for advanced users only, it’s possible to introduce new customized topics with the help of woocommerce_webhook_topic_hooks filter.
  • Delivery URL: URL where the webhook payload is delivered.
  • Secret: The a Secret Key is used to generate a hash of the delivered webhook and provided in the request headers. This will default to the current API user’s consumer secret if not provided.

3. Save Webhook.

Note: On the first time your webhook is saved with the Activated status will be sent a ping to the Delivery URL.

Editing and deleting Webhooks ↑ Back to top

Webhooks are listed the same way as posts or products, and you can edit or delete using the Edit and Trash links.

webhooks list

Webhook logs ↑ Back to top

WooCommerce saves logs of all events triggering a webhook. Select a webhook and click Edit. Logs are at the bottom of the page.

woocommerce-webhook-log

Logs may be reviewed to see deliveries and the response from the server, making it simpler to integrate and debug.

↑ Back to top

WooCommerce - the most customizable eCommerce platform for building your online business.

Back to the top