=== Zefirox for WooCommerce ===
Contributors: zefirox
Tags: group buying, dynamic pricing, tiered pricing, countdown, campaign
Requires at least: 6.2
Tested up to: 6.9
Requires PHP: 7.4
WC requires at least: 8.0
WC tested up to: 10.3
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Time-limited group-buying campaigns with tiered pricing: the more units are sold, the lower the final price for everyone.

== Description ==

Zefirox runs time-limited campaigns where the price drops as sales reach quantity tiers. This plugin connects your WooCommerce store to Zefirox:

* **Live widget on product pages** — current price, next tier, potential final price, progress bar and countdown. Added automatically to mapped products or anywhere with the `[zefirox_widget]` shortcode.
* **Product and variation mapping** — set a Zefirox campaign ID on a product; variations can override it.
* **Paid-order reporting** — when an order is paid (payment complete / processing / completed) the plugin sends one signed request per campaign to Zefirox, with quantities and amounts in minor units (cents).
* **Reliable delivery** — HMAC-SHA256 signed requests, idempotency keys, background sending through Action Scheduler with automatic retries, result stored on the order and visible in order notes, plus a "Resend to Zefirox" order action.
* Compatible with High-Performance Order Storage (HPOS) and the Cart/Checkout blocks.

= External service =

This plugin connects to the Zefirox service, which you configure in WooCommerce → Zefirox:

* The **Zefirox API** (default `https://zefirox-api.onrender.com`) receives, for each paid order containing a mapped product: campaign ID, order ID, quantity, amount, currency, the payment transaction ID and the WooCommerce customer ID (as `wc-customer-<id>`). No names, e-mail or addresses are sent.
* The **widget script** (default `https://zefirox-dashboard.onrender.com/dms-widget.js`) is loaded on product pages that have a campaign; visitors' browsers then request the public campaign status from the Zefirox API.

Zefirox privacy policy: https://zefirox-dashboard.onrender.com/privacy

== Installation ==

1. Upload the `zefirox-woocommerce` zip in Plugins → Add New → Upload Plugin, then activate it (WooCommerce must be active).
2. In your Zefirox merchant dashboard create a campaign and an API key.
3. Go to WooCommerce → Zefirox and enter the API URL, the widget script URL and the API key.
4. Edit a product → General tab → "Zefirox campaign ID" (or per variation in the Variations tab).
5. Place a test order and check the order notes: "Zefirox: order reported to campaign …".

Optional `wp-config.php` overrides: `ZEFIROX_API_URL`, `ZEFIROX_WIDGET_URL`, `ZEFIROX_API_KEY`.

== Frequently Asked Questions ==

= When is an order sent to Zefirox? =

Only once it is paid (status processing or completed, or when the gateway reports payment complete). Pending, on-hold and failed orders are not sent. Each campaign in an order is reported once; retries are safe thanks to idempotency keys.

= Can I place the widget manually? =

Yes: `[zefirox_widget]` on a product page, `[zefirox_widget product_id="123"]`, or `[zefirox_widget campaign_id="UUID"]`. Disable "Show the widget automatically" in the settings if you only want the shortcode. One widget per page is supported.

= What if the Zefirox API is down? =

Orders are queued in Action Scheduler (WooCommerce → Status → Scheduled Actions, group `zefirox`) and retried up to 6 times over ~10 hours. Failures are written to the order notes and to WooCommerce → Status → Logs (source `zefirox`).

= What is removed on uninstall? =

Settings, product/variation campaign IDs and pending jobs. Order notes and the `_zefirox_sync` order meta are kept as an audit trail.

== Changelog ==

= 1.0.0 =
* Rewrite: settings with sanitisation, variation mapping, signed + idempotent order reporting on payment, Action Scheduler retries, HPOS and Cart/Checkout blocks compatibility, configurable widget URL, uninstall cleanup, translations ready.

= 0.1.0 =
* Initial prototype.
