=== Response360 ===
Contributors: response360
Tags: whatsapp, woocommerce, click to chat, notifications, customer communication
Requires at least: 5.8
Tested up to: 6.6
Requires PHP: 7.4
Stable tag: 1.2.0
WC requires at least: 6.0
WC tested up to: 9.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Connect WordPress / WooCommerce to Response360: a floating click-to-WhatsApp button and automated WhatsApp order notifications.

== Description ==

Response360 links your site to your Response360 account so you can reach customers on WhatsApp.

Three features:

1. **Click-to-WhatsApp widget** — a floating button on your site that opens a WhatsApp chat (via a standard wa.me link) with an optional prefilled message. Configurable label, color, position, and optional business-hours visibility. You can also place an inline button anywhere with the `[response360_whatsapp]` shortcode or the "Response360 WhatsApp Button" block. This is a plain link; no credentials touch the browser.

2. **WooCommerce order notifications** — when an order reaches a status you choose (e.g. received, shipped, refunded), Response360 sends the customer a WhatsApp message on your behalf. Sends run server-side, never block checkout, are de-duplicated per status, and are logged to the WooCommerce log. Consent is configurable: opt-out (notify unless disabled per order) or opt-in (a checkout checkbox the customer must tick — recommended for GDPR/KVKK).

3. **WordPress email delivery (optional)** — route this site's outgoing WordPress emails (password resets, WooCommerce order emails, contact-form notifications, etc.) through Response360, delivered from your own verified sending domain (DKIM/SES). No separate SMTP plugin is required. This is **fail-safe**: if the API key is missing, an email carries attachments, or a send fails for any reason, that email is delivered by WordPress' normal mail path, so your site email is never broken.

All server-side messaging goes through the Response360 API (`POST /v1/messages` for WhatsApp, `POST /v1/email` for email). Your API key is stored on the server and never exposed to visitors. A one-click **Test connection** button on the settings page confirms the key is valid.

Compatible with WooCommerce High-Performance Order Storage (HPOS). The widget works with or without WooCommerce.

== Installation ==

1. Upload the `response360` folder to `/wp-content/plugins/`, or install the ZIP via Plugins → Add New → Upload Plugin.
2. Activate the plugin through the Plugins screen.
3. Go to **Settings → Response360**.
4. Paste your **API Key** (generate it in your Response360 panel under **Integrations → API keys**). Leave the API Base URL as the default.
5. Save, then click **Test connection** to confirm the key works.
6. Enable and configure the widget and/or WooCommerce notifications.

For an inline button on any page or post, add the shortcode `[response360_whatsapp]` (optional attributes: `number`, `text`, `label`) or insert the "Response360 WhatsApp Button" block.

== Frequently Asked Questions ==

= Where do I get an API key? =
In your Response360 panel, under **Integrations → API keys**. Keys look like `r360_live_...`.

= Is my API key safe? =
Yes. It is stored in the WordPress options table on your server and is only used for server-side API calls. It is never printed on the page or sent to the browser. The click-to-WhatsApp widget uses a public wa.me link and does not use the key at all.

= Will a failed notification break my store? =
No. WooCommerce notification sends are wrapped so any API failure is logged (WooCommerce → Status → Logs, source "response360", and as an order note) but never interrupts checkout or order processing.

= What message placeholders can I use? =
`{order_number}`, `{first_name}`, `{last_name}`, `{total}`, `{status}` (human-readable order status) and `{site}`.

= How does customer consent work? =
Two modes. **Opt-out** (default): every eligible order is notified, and you can disable notifications on an individual order from its edit screen. **Opt-in**: notifications are only sent to customers who tick a "Send me order updates on WhatsApp" checkbox at checkout — recommended for GDPR/KVKK compliance.

= Can I limit the floating button to business hours? =
Yes. Enable "Business hours" in the widget settings and set a start/end time (your WordPress timezone). Overnight ranges such as 22:00–06:00 are supported.

= Can I send my WordPress emails through Response360? =
Yes. Under **Settings → Response360 → WordPress email delivery**, enable "Send emails via Response360". It requires a saved API key and a verified sending domain in your Response360 panel (optionally pick a specific "From domain"; blank uses your account default). Every `wp_mail()` call is then delivered via `POST /v1/email` from your DKIM/SES-verified domain — no separate SMTP plugin needed. It is fail-safe: if the key is missing, the email has attachments, or a send fails for any recipient, WordPress falls back to its normal mail path so no email is ever lost.

== Roadmap ==

* Template-based (pre-approved) WhatsApp message sends.
* More WooCommerce triggers and richer placeholders.
* Additional Response360 channels.

== Changelog ==

= 1.2.0 =
* Added optional WordPress email delivery through Response360: route all outgoing `wp_mail()` email via `POST /v1/email` from your own verified sending domain (DKIM/SES) — no separate SMTP plugin required.
* Fail-safe by design: missing API key, attachments, or any send failure falls back to WordPress' normal mail path so site email is never broken. Optional "From domain" selector.

= 1.1.0 =
* Added "Test connection" button on the settings page (live API key validation).
* Added `[response360_whatsapp]` shortcode and a "Response360 WhatsApp Button" block for inline buttons.
* Added optional business-hours visibility for the floating widget (overnight ranges supported).
* Added opt-in consent mode: a customer WhatsApp-consent checkbox at checkout (GDPR/KVKK), alongside the existing per-order opt-out.
* Added `{status}` and `{last_name}` message placeholders; `{status}` renders the human-readable status name.
* Notifications now log to the WooCommerce logger (source "response360").
* Added concurrency-safe send lock and uninstall cleanup.

= 1.0.0 =
* Initial release: settings page, click-to-WhatsApp widget, WooCommerce order-status notifications via Response360 API.
* WooCommerce HPOS (custom order tables) compatible.
* Per-order opt-out, per-status de-duplication, checkout never blocked on API failure.
* Settings link on the Plugins screen; admin notice when notifications are enabled without WooCommerce.
