=== Babylon Care Connector ===
Contributors: babyloncore
Tags: woocommerce, orders, delivery, tracking, iraq
Requires at least: 5.8
Tested up to: 6.7
Requires PHP: 7.4
Requires Plugins: woocommerce
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Links your WooCommerce store to your own Babylon Care: new orders are sent to Care, delivery updates come back, and customers see their tracking number.

== Description ==

Babylon Care Connector connects a WooCommerce store to a Babylon Care installation that you own (the "store link"). You paste one key, press Save, and the plugin does the rest.

What it does:

* Sends new WooCommerce orders to Babylon Care for review and delivery. Cash on delivery orders are sent when they are processing or on hold; orders paid online are sent as "already paid" so the courier collects nothing.
* Receives updates from Care (approved, rejected, handed to the delivery company, delivered, cancelled...) and records them as private order notes. Only "delivered" completes an order and only "rejected/cancelled" cancels it; everything else is a note, so you stay in control.
* Shows the Care order number as the **tracking number** on the order screen, in My Account, and in customer emails.
* Matches the customer's governorate and area with the delivery company list automatically. If it cannot, the order screen shows two dropdowns so you can pick them.
* Offers your products and their variations (colours) to Care's product picker.
* Asks Care to cancel when you cancel a sent order in WooCommerce (Care staff decide).
* Works with High-Performance Order Storage (HPOS) and the block checkout.

Security:

* Every message in both directions is signed with HMAC-SHA256 and verified in constant time.
* Replay protection: a 5 minute time window plus a one-time nonce table.
* Your key is stored encrypted (AES-256-GCM) and is never displayed again.
* Outbound connections are HTTPS only, never follow redirects, time out after 10 seconds and refuse private or internal addresses.
* Rate limits on every public route; nothing secret is ever written to a log.
* Admin actions require the "manage_woocommerce" capability and a nonce.

Languages: English and Arabic (right-to-left) are included.

= External service =

This plugin talks only to the Babylon Care server whose address is inside the link key you paste (your own installation or the one your provider gave you). It sends, for each order that qualifies: customer name, phone numbers, delivery address, order lines, totals and the customer note. It sends nothing else and nothing to any other party. Disconnecting (or deleting the plugin) tells Care to stop sending messages.

== Installation ==

1. Make sure WooCommerce is active and your store uses HTTPS and sits at the root of its domain.
2. Upload the plugin zip under Plugins > Add New > Upload Plugin, then activate it.
3. In Babylon Care open Settings, find the online store link and create a link key. Copy it.
4. In WordPress open WooCommerce > Babylon Care, paste the key, and press "Save and connect". The status turns green.

== Frequently Asked Questions ==

= Where do I get the key? =
From your Babylon Care settings (online store link). It starts with `bsl1.`

= Does it work with a store in a sub-folder (example.com/shop)? =
No. Care reaches your store at fixed paths on the domain root (`/api/care/...`).

= Why was an order not sent? =
Open the order: the "Babylon Care" box on the side says why. The common reasons are a delivery area that could not be matched (pick it from the dropdowns and press Update) or a missing phone number.

= Are unpaid bank-transfer orders sent? =
No. Only cash on delivery orders, and orders that are already paid, are sent, so the courier is never asked to collect money that was not agreed.

= Is the currency important? =
Yes. Babylon Care works in Iraqi dinar. Orders in other currencies are skipped and marked as such.

= Are customer reviews imported from Care? =
Not in this version.

== Changelog ==

= 1.0.0 =
* First release: signed link, order push with retries, Care events, tracking number, catalog for Care's product picker, HPOS support, Arabic and English.

== Upgrade Notice ==

= 1.0.0 =
First release.
