=== OrderPing – Order Notifications for WooCommerce ===
Contributors: alithenu, freemius
Tags: woocommerce, order notifications, whatsapp, cloud api
Requires at least: 6.4
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Send WooCommerce order notifications on WhatsApp using the official WhatsApp Cloud API. No middleman subscription.

== Description ==

OrderPing sends WooCommerce order updates to your customers on WhatsApp, and new-order alerts to you.
It connects directly to Meta's official WhatsApp Cloud API with your own account – no middleman subscription, you only pay Meta's own message prices.

= Free features =

* "Order received" and every order status message (processing, completed, on hold, cancelled, refunded, failed, notes to the customer and your custom statuses)
* New order alert to the shop owner on WhatsApp
* English and Arabic messages, chosen per customer
* Use OrderPing's ready-made templates or your own approved templates
* Checkout consent notice or opt-in box, STOP / START replies, opt-out list, privacy export and erase
* Delivered / read status for every message, message log and resend
* Floating "Chat on WhatsApp" button, product page "Order on WhatsApp" buttons and QR codes
* Test mode and a one-click self-test

= OrderPing Pro =

* Cash on delivery confirmation with "Confirm order" / "Cancel order" buttons, reminders and automatic cancel
* Phone verification with a WhatsApp code at checkout
* "Pay now" reminders for unpaid online orders
* Abandoned cart reminders with personal discount codes
* Invoice PDF, "Order shipped" with tracking link, and review requests
* Staff alerts to up to 10 numbers, quiet hours in the customer's time zone
* Template editor and WhatsApp cost report

OrderPing Pro is a one-time purchase with lifetime updates.

= External services =

This plugin connects to the Meta WhatsApp Cloud API (graph.facebook.com) to send messages and manage message templates, using the account details you enter. Order details needed for each message (name, order number, total, phone number) are sent to Meta when a message is sent. Meta terms: https://www.whatsapp.com/legal/business-terms – privacy: https://www.whatsapp.com/legal/privacy-policy
Licensing and updates use Freemius only if you opt in or activate a Pro licence: https://freemius.com/privacy/

== Installation ==

1. Install OrderPing from Plugins → Add New (search "OrderPing"), or upload the zip, and activate it. WooCommerce must be active.
2. Go to WooCommerce → OrderPing → Connection and enter your WhatsApp Cloud API access token, Phone number ID and WhatsApp Business Account ID (from developers.facebook.com → your app → WhatsApp → API Setup).
3. Add the shop owner's WhatsApp number and click "Send test message".
4. Open the Templates tab and click "Create templates in my WhatsApp account". Meta usually approves them within minutes to a few hours; click "Refresh status" to check.
5. Optional: set up delivery tracking (webhook) on the Connection tab to see Delivered / Read and to handle STOP replies.
6. Turn off Test mode on the Messages tab when you are ready to go live.

== Frequently Asked Questions ==

= Do I need a WhatsApp Business API account? =

Yes. OrderPing uses Meta's official WhatsApp Cloud API. Creating the account is free; Meta charges per message conversation according to its own price list. OrderPing adds no extra fees.

= Will my customers get spam? =

No. Messages are only sent for their own orders, the checkout can ask for consent, and customers can reply STOP at any time to stop all messages.

= Does it work with the block checkout and HPOS? =

Yes. OrderPing supports both the classic and the block checkout, and WooCommerce High-Performance Order Storage.

= Can I try it without sending real messages? =

Yes. Test mode shows every message in the message log and order notes without sending anything, and the self-test (Connection tab) checks the whole plugin in a few seconds.

= Which languages are supported? =

Messages are available in English and Arabic; OrderPing picks the language for each customer. The plugin itself is translation-ready.


== Changelog ==

= 1.0.1 =
* Shop scripts and styles are now loaded as files (no inline code), and only on the pages that use them.
* Removed the "Contact Us" menu item.

= 1.0.0 =
* Free and Pro versions. Pro (one-time purchase) adds COD confirmation, phone verification, payment and abandoned cart reminders, invoices, tracking, reviews, staff alerts, quiet hours and the template editor.
* Built-in self-test (Settings → Connection → Self-test): one click runs over 60 checks of order messages, COD buttons, payment reminders, tracking, invoices, reviews, staff alerts, quiet hours, the webhook, STOP replies and abandoned carts on your own site, in Test mode, and removes everything it created.
* A message can no longer be sent twice when two background workers pick it up at the same time.
* Messages held for quiet hours go back to the queue correctly.
* Works on servers without the mbstring extension.

= 0.9.0 =
* Invoice PDF on WhatsApp: the order's invoice attached as a document when the order reaches a status you choose (uses "PDF Invoices & Packing Slips for WooCommerce", or any invoice plugin through the orderping_invoice_pdf filter). Your own templates with a document header get the invoice too.
* Shipment tracking: courier and tracking number in the order's WhatsApp box (or from Advanced Shipment Tracking / WooCommerce Shipment Tracking) send an "Order shipped" message with a "Track order" button. Editable tracking links for Aramex, SMSA, DHL, FedEx, UPS, Naqel, Emirates Post, Saudi Post and others. Only fresh tracking numbers are messaged.
* Review requests a set number of days after an order is completed (or any status), with a "Write a review" button to the main product's review form; skipped for cancelled/refunded orders.
* Staff alerts: up to 10 extra people, each choosing new orders and/or any order statuses (e.g. warehouse gets Processing).
* Quiet hours in the customer's own time zone (from the phone's country code): hold reminders, or all customer messages, until morning. COD confirmations and staff alerts always go at once.

= 0.8.0 =
* Chat on WhatsApp: floating chat button (position, where to show, hide on phones/computers, label), pre-filled message with {product}, {product_url}, {price}, {store}, {page_url}, {page_title}.
* Product pages: "Order on WhatsApp" button (product, chosen options, quantity, price, link) and "Share on WhatsApp" link.
* [orderping_chat] and [orderping_qr] shortcodes and a "WhatsApp chat button" block (button or QR code).
* Shop QR code made inside the plugin (no outside service), with SVG download for printing.
* Setup checklist on the settings page (connection, owner number, test message, templates approved, delivery tracking, go live) – ticks itself off; opens after activation.
* WooCommerce → WhatsApp usage: sent, delivered, read and failed by message, by Meta pricing category (charged vs free, from delivery updates), common errors, messages per day, and a cost estimate from your own rates.

= 0.7.0 =
* Settings in tabs: Connection, Messages, COD & verification, Carts & payments, Consent, Templates.
* Use any approved template from your WhatsApp account for any message, and choose what fills each {{variable}} (name, order number, total, products, address, tracking number, links…), with a live preview. Text and image headers and link buttons are supported.
* Template editor: write your own English/Arabic template with header (text or image), footer and up to 3 buttons (quick reply, link, call). Live checks for Meta's rules (variables at the start/end or side by side, numbering, length, promotional words) and a WhatsApp-style preview.
* Safe versioning: submit a new version (e.g. name_v2) and choose "Use for" – the current template keeps sending until Meta approves the new one, then the message switches automatically (on "Refresh status").
* Template status now reads all templates (all pages) with their content.
* Optional Meta App ID setting (needed only for image headers).

= 0.6.0 =
* Abandoned cart reminders: when a shopper types their phone at checkout and leaves, 1–3 WhatsApp reminders (delays you choose) with a "Complete order" button that restores the cart and opens the checkout. English and Arabic.
* Optional personal single-use coupon (percent or fixed, expiry) in the first or last reminder, applied automatically.
* WooCommerce → Abandoned carts: carts saved, reminded, link opened, recovered orders, recovered revenue (30 days), list with status and "Send now".
* Stops automatically when the shopper orders, empties the cart or replies STOP. Minimum cart total. Old carts deleted after 90 days. Privacy export/erase.
* Payment reminders: online-paid orders still "Pending payment" or "Failed" get a reminder with a "Pay now" button (signed link to the order's payment page). Optional second reminder and automatic cancellation. Never for cash on delivery.
* Templates can now have a link button and the MARKETING category.

= 0.5.1 =
* Checkout phone verification: the customer gets a 6-digit code on WhatsApp (Meta authentication template with a Copy code button, English and Arabic) and enters it before placing the order. Classic and block checkout.
* Choose cash on delivery only or all payment methods, and everyone or guests only. Logged-in customers verify each number once.
* Secure: codes are hashed, expire after 10 minutes, 5 attempts, resend after 60 seconds, max 3 codes per number per 15 minutes and 10 per IP per hour.
* Never blocks sales: if the shop's WhatsApp has a problem, or the number is not on WhatsApp, the order can still be placed and the order screen shows it.
* Optional: skip the COD confirmation message when the phone was verified with a code.
* Test mode shows the code on the checkout page instead of sending it.

= 0.5.0 =
* Cash on delivery confirmation: COD customers get a WhatsApp message with "Confirm order" and "Cancel order" buttons (English and Arabic).
* Confirm moves the order from On hold to Processing; Cancel cancels it and WooCommerce restocks. The customer gets a short reply either way.
* Optional reminder and automatic cancellation when there is no reply (only when the request was delivered).
* Order screen: confirmation status, "Mark as confirmed" / "Cancel order" for phone confirmations, and a simulate option in Test mode.
* New "COD confirmation" column in the orders list.
* Buttons are signed, and only the customer's own number can confirm or cancel.
* New consent mode "Notice" (recommended, default for new installs): a short line above "Place order" names the shop, says updates come on WhatsApp and how to stop them. Works on classic and block checkout; recorded on the order with time and IP.
* Order note explains why a COD order did not get a confirmation request.
* Saving new connection details clears the old connection error notice.

= 0.4.0 =
* Customer consent: optional "Send me order updates on WhatsApp" checkbox on the classic and block checkout, saved with time and IP.
* Customers can reply STOP / إيقاف to stop messages (with a confirmation) and START / ابدأ to subscribe again.
* New "WhatsApp" tab in My Account to change the WhatsApp number or stop messages.
* Opted-out numbers list in settings, with Remove and manual add.
* Country code is now taken from the order's billing country.
* Works with Tools → Export / Erase Personal Data.
* Message log: new "Skipped" status with the reason, and a purple "Test" label for Test mode messages.

= 0.3.1 =
* Test mode: preview every message with real order details in the log and order notes without sending anything.
* The message log now shows each message's text exactly as the customer reads it.
* Sending a message manually from the order screen now counts as sent, so the automatic message isn't repeated.
* Clear warnings for account problems (locked account, payment method needed, expired token): admin notice, email and no pointless retries.
* Templates are created only for the messages you switched on, a few at a time, to be gentle with new WhatsApp accounts.

= 0.3.0 =
* Instant sending: messages go out right after the customer's page has loaded, with automatic retries (1, 5 and 30 minutes) on temporary errors.
* Message log (WooCommerce → OrderPing Log) with Sent / Delivered / Read / Failed, error details, search and Resend.
* Webhook for delivery and read receipts, verified with your Meta app secret.
* Connection health check (daily and on demand), admin warning and email when the token stops working, and Site Health tests.
* New messages: on hold, refunded, payment failed, note to customer, and custom order statuses from other plugins.
* Per-message rule: all orders, Cash on delivery only, or prepaid only.
* "Send WhatsApp" box on the order screen with the order's latest messages.
* Arabic messages show amounts as "249.00 د.إ" and common payment methods in Arabic.
* Access token and app secret are stored encrypted.
* Deleting the plugin removes all its data.

= 0.2.1 =
* Settings page no longer contacts Meta while loading; template status is checked only when you click "Refresh status".
* Shorter network timeout so a slow connection can't freeze WP Admin.

= 0.2.0 =
* Own message templates in English and Arabic, created in your WhatsApp account with one click, with approval status shown in settings.
* Order processing, completed and cancelled messages.
* New order alert for the shop owner with order number, total, payment method and customer.
* Automatic language: messages follow the language the customer used on the site.
* Messages are sent in the background so checkout stays fast.

= 0.1.0 =
* First development version: settings page, test message, new-order messages for customer and shop owner, results logged as order notes.
