=== Huwiya ===
Contributors: huwiya
Tags: woocommerce, erp, orders, inventory, integration
Requires at least: 5.8
Tested up to: 7.0
Requires PHP: 8.0
Stable tag: 1.0.8
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Connect your WooCommerce store to Huwiya ERP via webhooks and REST API.

== Description ==

Huwiya connects your WooCommerce store to [Huwiya ERP](https://huwiya.sa) for order sync, product updates, and inventory management.

**Features**

* Order webhooks on create and update
* Historical orders sync 
* REST API for products (list, create, update)
* Admin page to verify and save your API key

**Requirements**

* WooCommerce 8.0 or later
* PHP 8.0 or later
* A Huwiya account and API key

== Installation ==

1. Upload the plugin files to `/wp-content/plugins/huwiya`, or install through the WordPress plugins screen.
2. Activate the plugin through the **Plugins** screen.
3. Ensure WooCommerce is installed and active.
4. Go to **Huwiya → Verification**, accept the Terms and Privacy Policy, and enter your API key from Huwiya ERP.
5. Optional: use **Huwiya → Historical Orders** to sync past orders by date range.

== External services ==

This plugin connects your WooCommerce store to **Huwiya ERP**, a third-party business management service. Outbound requests are sent to Huwiya-hosted endpoints (Supabase Edge Functions). No data is sent until a store administrator explicitly agrees to the Terms of Service and Privacy Policy and verifies an API key.

**Service:** Huwiya ERP (https://huwiya.sa)

**What is sent and when:**

* **API key verification** — When you click "Verify & Save" on the Verification page (after consent): store domain, site URL, site name, admin email, WooCommerce store ID, WooCommerce/WordPress versions, currency, timezone, and plugin version.
* **Store activation** — Once, after the first successful API key verification: the same store metadata.
* **Order create/update** — When a WooCommerce order is created or meaningfully updated (only after the store is connected): order details, customer billing/shipping, line items, totals, and payment/shipping status.
* **Historical orders** — When you start a sync from **Huwiya → Historical Orders**: batches of orders within the date range you select.
* **Store deactivation** — When the plugin is deactivated, only if the store was previously connected: store metadata.

**Inbound requests:** Huwiya ERP may call your site's REST API (products, orders) after you connect the store. Those requests are initiated by your ERP account, not by background tracking.

**Legal:**

* Terms of Service: https://huwiya.sa/ar/terms
* Privacy Policy: https://huwiya.sa/ar/privacy
* FAQs: https://huwiya.sa/ar/faqs

== Frequently Asked Questions ==

= Does this plugin work without WooCommerce? =

No. WooCommerce must be installed and active.

= Where do I get an API key? =

In Huwiya ERP: **System Settings → Developer & Automation → Developer Settings**.

= Is any data sent when I only activate the plugin? =

No. Outbound data is sent only after you accept the Terms and Privacy Policy and verify your API key on the Verification page.

== Changelog ==

= 1.0.8 =
* Opt-in consent before connecting to Huwiya ERP; no outbound calls on plugin activation alone.
* Deactivation webhook only when the store was previously connected.
* Documented external services in readme; upgraded firebase/php-jwt to 7.x; PHP 8.0 minimum.

= 1.0.7 =
* WordPress Plugin Check compliance: wp_parse_url, sanitized server vars, admin form rendering.

= 1.0.6 =
* Main plugin file restored as huwiya.php; legacy huwiya-woocommerce.php loader kept for compatibility.
* Release zip now mirrors manual folder packaging.

= 1.0.5 =
* Release zip layout fixed to match folder `huwiya/huwiya-woocommerce.php`.

= 1.0.4 =
* Fix WordPress install path: main file is now huwiya-woocommerce.php (fixes activation error).

= 1.0.3 =
* Updated plugin configuration for historical orders webhook URL.

= 1.0.2 =
* Historical orders: admin sync via webhook batches and GET `/orders/historical` REST endpoint.

= 1.0.1 =
* Initial public release.

== Upgrade Notice ==

= 1.0.8 =
Adds opt-in consent for ERP connection, external services documentation, and PHP 8.0 requirement.

= 1.0.7 =
Plugin Check compliance fixes; no functional changes.

= 1.0.6 =
Fixes activation path huwiya/huwiya.php on existing installs.

= 1.0.5 =
Fixes release zip folder layout for WordPress activation.

= 1.0.4 =
Fixes plugin activation on sites expecting huwiya-woocommerce folder.

= 1.0.3 =
Configuration update for historical orders sync.

= 1.0.2 =
Adds historical order sync and paginated orders API.

= 1.0.1 =
Initial release.
