=== Webhook For WooCommerce ===
Contributors: softtent
Tags: webhook, woocommerce, automation, http, notification
Requires at least: 6.2
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 0.1.2
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Author: SoftTent
Author URI: https://softtent.com

Send real-time HTTP webhook notifications to any external URL when WooCommerce events occur — orders, payments, customers, stock, and more.

== Description ==

WebhookX is a lightweight, developer-friendly webhook manager for WordPress and WooCommerce. Create unlimited webhooks that fire automatically when WooCommerce actions happen, and deliver rich JSON payloads to any external endpoint in real time.

= Key Features =

* **WooCommerce event triggers** — Hook into 11+ built-in WooCommerce actions out of the box.
* **Custom delivery URL** — Send webhook payloads to any HTTP/HTTPS endpoint.
* **HMAC secret signing** — Optionally secure each webhook with a secret key. Requests include an `X-WebhookX-Signature` header (SHA-256 HMAC) so your endpoint can verify authenticity.
* **Active / Inactive status** — Enable or disable individual webhooks without deleting them.
* **Rich JSON payloads** — Payloads include full order details (line items, billing, shipping, totals), customer data, product stock info, and more.
* **Bulk delete** — Remove multiple webhooks at once from the management table.
* **Webhook delivery logs** — Every webhook delivery is automatically logged with status, HTTP response code, response body, payload, and execution duration. Browse, filter, retry, and delete log entries from a dedicated Logs tab.
* **Non-blocking delivery** — Webhooks are dispatched asynchronously so they never slow down your storefront.
* **Extendable** — Add custom events via the `webhookx_woocommerce_events` filter.

= Supported WooCommerce Events =

* New Order Created
* Order Status Changed
* Payment Complete
* Checkout Order Processed
* Order Completed
* Order Cancelled
* Order Refunded
* Customer Created
* Add to Cart
* Product Stock Updated
* Product Stock Status Changed

= Webhook Payload =

Each webhook delivers a JSON `POST` body. For order events this includes:

* Order ID, status, currency, totals (subtotal, tax, shipping, grand total)
* Full billing and shipping address
* Line items with product ID, name, quantity, and totals
* Customer ID and email
* Order creation timestamp

For customer events: customer ID, email, username, first/last name.
For cart events: product ID, name, quantity, variation ID.
For stock events: product ID, name, SKU, stock quantity / status.

= Request Headers =

Every webhook request includes:

* `Content-Type: application/json`
* `X-WebhookX-Event` — the WooCommerce action slug that fired
* `X-WebhookX-Delivery` — a unique UUID per delivery
* `X-WebhookX-Signature` — SHA-256 HMAC signature (only when a secret key is set)

= Webhook Logs =

Every webhook delivery attempt is recorded in a dedicated **Logs** tab. Each log entry includes:

* **Status** — `success`, `failed`, or `pending`
* **HTTP response code** — the status code returned by the remote endpoint
* **Webhook name & event** — which webhook fired and what triggered it
* **Delivery URL** — the endpoint the payload was sent to
* **Request payload** — the full JSON body that was delivered
* **Response body** — the raw response returned by the endpoint
* **Duration** — how long the delivery took in milliseconds
* **Timestamp** — when the delivery was made

From the Logs tab you can:

* Filter logs by status (All / Success / Failed)
* View full payload and response details in a modal
* **Retry** any individual delivery with one click
* **Delete** individual or bulk-selected log entries

== Installation ==

1. Upload the `webhookx` folder to `/wp-content/plugins/`.
2. Activate the plugin through the **Plugins** menu in WordPress.
3. Make sure WooCommerce is installed and activated.
4. Navigate to **WebhookX** in the WordPress admin menu.
5. Click **Add Webhook**, choose a WooCommerce event, enter your delivery URL, and save.

== Frequently Asked Questions ==

= Does this plugin require WooCommerce? =

Yes. WebhookX is designed to trigger webhooks based on WooCommerce events. WooCommerce must be installed and active for webhooks to fire.

= How do I verify the webhook came from my site? =

Set a **Secret Key** when creating a webhook. Each request will include an `X-WebhookX-Signature` header containing `sha256=<hmac>`. Compute `hash_hmac('sha256', $raw_body, $secret)` on your server and compare it to the header value.

= Can I add my own custom events? =

Yes. Use the `webhookx_woocommerce_events` filter to add your own event slugs to the event list in the UI. You are responsible for hooking the corresponding WordPress/WooCommerce action.

= How do I temporarily stop a webhook without deleting it? =

Edit the webhook and set its **Status** to **Inactive**. It will be ignored until you re-activate it.

= Where are webhook delivery logs stored? =

Logs are stored in a custom database table (`{prefix}webhookx_logs`). You can view all logs under the **Logs** tab in the WebhookX admin screen. Logs are created automatically for every delivery attempt — whether it succeeds or fails.

= Can I retry a failed webhook delivery? =

Yes. In the **Logs** tab, click the **⋮** actions menu next to any log entry and choose **Retry**. The plugin will re-dispatch the original payload to the same endpoint immediately. You will be notified whether the retry succeeded or received a non-2xx response.

= Where can I find documentation? =

For detailed documentation, visit [https://softtent.com](https://softtent.com).

= Need Any Help? =

Please mail us at `contact@softtent.com`

== Screenshots ==

1. Webhooks list — name, event, webhook URL, status, and created date.
2. Add/Edit webhook form — event selector, webhook URL, secret key, and status.
3. Webhook Logs tab — paginated webhook history with status badges, HTTP code, event, webhook name, duration, and date.
4. Log detail modal — full request payload and response body with status, HTTP code, and timing.

== Changelog ==

= 0.1.2 - May 20, 2026 =
* Tested: Compatibility with WordPress 7.0
* Added: Live chat support to our agent

= 0.1.1 =
* WooCommerce webhook management with 11 built-in event triggers.
* Add, edit, delete, and bulk-delete webhooks from the admin UI.
* HMAC SHA-256 request signing with optional secret key.
* Non-blocking async HTTP delivery via `wp_remote_post`.
* Rich JSON payloads for orders, customers, cart, and stock events.
* Active/Inactive webhook status toggle.
* Added **Webhook Logs** — every delivery attempt is now recorded with status, HTTP code, response body, payload, and duration.
* New **Logs tab** in the admin UI with paginated, filterable log history (All / Success / Failed).
* **Retry** any failed or successful delivery directly from the Logs tab.
* **Bulk delete** log entries from the Logs tab.
* Log detail modal showing full request payload and response body.
* Fixed plugin-check warnings for direct database queries in `Webhook.php` and `WebhookLog.php`.

== Additional Information ==

For more information and updates, visit the official website [https://softtent.com](https://softtent.com).

== License ==

This plugin is licensed under the GPL-2.0-or-later License.

