=== Yakeen – COD Order Confirmation for WooCommerce ===
Contributors: eslamelshenawy9316
Tags: cash on delivery, cod, order confirmation, whatsapp, woocommerce
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.2.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Stop shipping fake cash-on-delivery orders. Customers confirm or cancel their order with one tap in a WhatsApp message before you ship.

== Description ==

Every cash-on-delivery order that gets refused at the door costs you shipping, packing and time. **Yakeen** asks the customer to confirm the order on WhatsApp first, so you only ship orders that people actually want.

= How it works =

1. A customer places a cash-on-delivery order. Yakeen puts it on **Awaiting confirmation** and reserves the stock.
2. The customer receives a WhatsApp message with two buttons: **Confirm order** and **Cancel order**.
3. **Confirm** moves the order to *Processing* in one tap, and the customer gets your usual order email.
4. **Cancel** asks "Are you sure?" first, then cancels the order and puts the stock back.
5. No answer? The order is cancelled automatically after 24 hours (you choose the delay, or turn it off).

= Features =

* One-tap **Confirm** and **Cancel** buttons inside the WhatsApp message.
* **Arabic and English** messages, in your store's language or the one you choose.
* **Creates the WhatsApp message templates for you** with one click. No need to open WhatsApp Manager.
* **Auto-cancel** unconfirmed orders after a delay you choose, with stock restored.
* Stock is reserved while the order waits for confirmation, so confirmed orders are never oversold.
* Understands local phone formats, including Arabic-Indic digits (٠١٠…) and numbers without a country code.
* Order notes show when the message was sent, confirmed or cancelled, and why a message failed.
* **Resend** the confirmation message from the order screen.
* Works with the classic and the block (Cart & Checkout blocks) checkout, and with High-Performance Order Storage (HPOS).

= Yakeen Pro and Yakeen Business =

Yakeen Pro and Yakeen Business are separate premium plans, sold on our website. They are not included in this plugin, and this free plugin works fully on its own.

**Yakeen Pro** adds:

* A WhatsApp **reminder** for customers who haven't answered yet.
* A WhatsApp **shipping message** telling the customer the order is on its way and how much to pay.
* **Address editing** for customers from the confirmation page, until the order ships.
* Messages in **each customer's own language** (WPML).
* **Statistics** showing the shipping money you saved, with 30 and 90-day history.
* **Abandoned cart recovery**: a WhatsApp message with a "Complete my order" button for shoppers who entered their phone at checkout but did not order, with an optional coupon, opt-in checkbox and one-tap unsubscribe.

**Yakeen Business** includes everything in Pro, plus:

* **COD protection**: hide cash on delivery for customers who refused deliveries before, never answered the confirmation, or are on your blacklist (phone, email or IP), with a trust badge for every order.
* **Log in with WhatsApp**: customers log in or sign up with their phone number and a code sent on WhatsApp, with no password.

= Uses your own WhatsApp number =

Messages are sent from **your** WhatsApp Business number through Meta's official WhatsApp Cloud API. There is no middleman and no extra per-message fee from us. Meta bills WhatsApp conversations directly to your Meta account.

== Installation ==

1. Install and activate the plugin. WooCommerce must be active.
2. In Meta for Developers, create an app with the WhatsApp use case, and a System User token with the `whatsapp_business_messaging` and `whatsapp_business_management` permissions.
3. Go to **WooCommerce → Settings → COD Confirmation** and enter your Phone number ID, WhatsApp Business Account ID and access token. Save.
4. Click **Create message templates** and wait until both show **Approved** (usually minutes to a few hours).
5. That's it. New cash-on-delivery orders now ask for confirmation.

== Frequently Asked Questions ==

= Do I need a WhatsApp Business API account? =

Yes. You need a WhatsApp number connected to the WhatsApp Cloud API in Meta for Developers. Setting one up is free; Meta charges per message according to its pricing.

= Which orders are affected? =

Only orders paid with WooCommerce's built-in **Cash on delivery** method that have a billing phone number. All other orders are untouched.

= What happens if the customer doesn't answer? =

The order stays on *Awaiting confirmation*. After the delay set in the settings (24 hours by default) it is cancelled automatically and the stock is restored. Set the delay to 0 to never cancel automatically.

= Can I confirm an order myself, for example after calling the customer? =

Yes. Change the order status to *Processing* as usual.

= Which languages are supported? =

The WhatsApp message is available in Arabic and English. The plugin interface is translation-ready and ships with an Arabic translation.

== External services ==

This plugin connects to the **WhatsApp Cloud API**, provided by Meta Platforms, Inc., to send the order confirmation message. It is required for the plugin to work.

* **When a cash-on-delivery order is placed**, or when you click *Resend WhatsApp confirmation*, the plugin sends the customer's phone number, first name, order number, order total and a confirmation link to `graph.facebook.com`.
* **On the settings page**, the plugin reads the review status of its message templates, and when you click *Create message templates* it sends the template text to `graph.facebook.com`.
* Your access token is sent with every request to authenticate your account. Nothing is sent to the plugin author.

Meta's terms and privacy policy apply:

* WhatsApp Business Solution Terms: https://www.whatsapp.com/legal/business-solution-terms
* Meta Platform Terms: https://developers.facebook.com/terms/
* Meta Privacy Policy: https://www.facebook.com/privacy/policy/

== Screenshots ==

1. The page the customer opens from the WhatsApp buttons: review the order, then confirm or cancel.
2. Settings under WooCommerce → Settings → COD Confirmation, including one-click template creation.
3. Yakeen stats (Pro): confirmation rate and the shipping money saved.

== Changelog ==

= 1.2.0 =
* Developer hook to customise a message template's full definition.
* Readme: WhatsApp login on the Business plan.

= 1.1.1 =
* Readme and stats page describe the Pro and Business plans.

= 1.1.0 =
* Arabic translation for the plugin name, description, settings and stats notes.
* Developer hooks for extra message templates (category, buttons, examples) and the stats page.
* Uninstall now also removes abandoned-cart data (Pro).

= 1.0.0 =
* First release.
