=== Chat App Brasil ===
Contributors: lupee
Tags: woocommerce, notifications, abandoned cart, chat, mensagens
Requires at least: 6.0
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 2.7.5
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

WhatsApp automation for WooCommerce. Order notifications, abandoned cart recovery, floating button, Mercado Pago PIX integration and mass messaging.

== Description ==

**Chat App Brasil** is the official WordPress integration with the [ChatAppBrasil](https://chatappbrasil.com/) platform, enabling you to automatically send WhatsApp messages to your customers directly from your site or store.

No technical complexity, no complex APIs — just enter your Access Token and start sending.

> **Requires an active account at [chatappbrasil.com](https://chatappbrasil.com/).** Create your free account and get your Access Token to get started.

---

= 🛒 Automatic WooCommerce Order Notifications =

Configure a different message for each order status:

* **New order** — sent on the thank you page, right after purchase
* **Pending, On Hold, Processing, Completed** order statuses
* **Cancelled, Refunded, Failed** order statuses
* **Order note** — when the store owner adds a note to the order
* **Admin notification** — receive a copy of each order on your WhatsApp
* **Custom statuses** — compatible with any custom status from other plugins

All messages support **spintax** `{Hello|Hi|Hey}` for random variations, and **dynamic tags** like `%billing_first_name%`, `%order_total%`, `%product_name%` and 20+ available variables.

---

= 🛒 Abandoned Cart Recovery =

Requires [CartBounty Free or Pro](https://wordpress.org/plugins/woo-save-abandoned-carts/):

* Up to **3 follow-up messages** with configurable hourly intervals
* **Aftersales message** sent X hours after order completion — ideal for reviews or upsells

---

= 💬 Floating WhatsApp Button =

* Inline SVG icon — no external images, loads instantly
* **4 positions** available with configurable horizontal and vertical offset
* Configurable size from 40 to 200px
* **Pulse effect**, tooltip and pre-filled message
* Hide on mobile, desktop or specific pages
* **Click tracking** with statistics dashboard

---

= 💳 Mercado Pago PIX Integration =

Native integration with **WooCommerce Mercado Pago** plugin (v8.x):

* Automatically detects PIX orders
* Sends the **PIX copy-and-paste code** via WhatsApp message
* Sends the **QR code** as an image attachment
* Special tag `%pix_code%` available in the configured message
* QR code image automatically deleted after 30 minutes
* If Mercado Pago is not installed, an informational banner is shown with an install link

---

= 📋 Form Integrations =

**Contact Form 7** — WhatsApp tab added directly in the form editor. Configure number, message and image using CF7 tags like `[your-name]` and `[your-tel]`.

**Caldera Forms** — Same concept with native panel in the editor. Uses `{slug}` instead of `[tag]`, with automatic field listing.

---

= 🛍️ Easy Digital Downloads =

* Phone field automatically added to EDD checkout
* **New order notification** — sent on the receipt page
* **Completed order notification** — sent when payment is confirmed

---

= 🔔 Back In Stock Notifier =

Native integration with the **Back In Stock Notifier for WooCommerce** plugin:

* Sent automatically when a product comes back in stock
* Triggered at the same time as the plugin's email notification
* Phone number is read from the field filled by the customer on the subscription form
* Available tags: `%name%`, `%product_name%`, `%product_url%`
* Product photo sent automatically as image
* Option for a fixed image (e.g. promotional banner) to replace the product photo
* Dedicated **🔔 Back In Stock** tab in Notifications with locked gate when plugin is not installed



* Share posts and products to a list of numbers
* Import WooCommerce customers
* Personalization with `%fname%` and `%lname%`

---

= 🔒 Security =

* Token validated before unlocking features
* All inputs sanitized with `wp_unslash()` and `sanitize_*`
* Nonces on all forms and AJAX actions
* Token never exposed in frontend JS — API calls made exclusively via PHP
* Compatible with **HPOS** (WooCommerce 7.1+)
* WordPress native **Privacy Policy** integration

---

= External Service =

This plugin transmits data (phone number, message, image) to the **ChatAppBrasil** API (`https://api.chatappbrasil.com`) solely to enable WhatsApp message delivery.

* [Terms of Service](https://chatappbrasil.com/termos)
* [Privacy Policy](https://chatappbrasil.com/privacidade)

---

= Compatibility =

* WordPress 6.0+ | WooCommerce 7.0+ with HPOS | PHP 7.4+
* Contact Form 7 | Caldera Forms | Easy Digital Downloads
* CartBounty Free and Pro | WooCommerce Mercado Pago 8.x

== Installation ==

1. Go to **Plugins → Add New → Upload Plugin**.
2. Select the `.zip` file and click **Install Now**.
3. Activate the plugin.
4. Go to **Chat App Brasil → Configuration**, enter your Access Token and click **Test Connection**.
5. Configure messages in **Chat App Brasil → Notifications**.
6. Customize the button in **Chat App Brasil → WhatsApp Button**.

== Frequently Asked Questions ==

= Do I need an account to use the plugin? =

Yes. An active account at [ChatAppBrasil](https://chatappbrasil.com/) with a valid Access Token is required.

= The floating button doesn't appear on my site. =

Make sure a phone number is entered in **Chat App Brasil → WhatsApp Button**. Without a number the button won't display.

= Messages are not being sent. =

1. Make sure the Access Token was validated successfully.
2. Check that the message for the corresponding status is not blank.
3. Check the log at **Chat App Brasil → Message Logs**.

= The WhatsApp tab doesn't appear in the CF7 editor. =

Make sure the Chat App Brasil plugin is active. The tab is added automatically to any CF7 form editor.

= Is the plugin compatible with WooCommerce HPOS? =

Yes. High-Performance Order Storage compatibility is declared automatically and tested with WooCommerce 7.1+.

= How does the Mercado Pago PIX integration work? =

When a customer places a PIX order, the plugin automatically reads the QR code and copy-and-paste code generated by the Mercado Pago plugin and sends them via WhatsApp. Requires WooCommerce Mercado Pago v8.x.

== Third-party Libraries ==

**International Telephone Input v15.0.2**
* Repository: https://github.com/jackocnr/intl-tel-input
* License: MIT
* Files: assets/js/intlTelInput.js, assets/css/intlTelInput.css, assets/js/utils.js

**jQuery Modal v0.9.1**
* Repository: https://github.com/kylefox/jquery-modal
* License: MIT
* File: assets/js/jquery.modal.min.js

== Changelog ==

= 2.7.5 - 05/2026 =

**Abandoned Cart — CartBounty**
* Full support for CartBounty Free and Pro with automatic version detection
* SQL query filters eligible carts directly using DATE_SUB — no false positives
* 24-hour filter: only carts abandoned in the last 24 hours are processed
* CartBounty Pro: uses wp_steps_completed and wp_last_sent for step control
* CartBounty Free: uses followup_1/2/3 columns for send tracking
* Dynamic column detection (SHOW COLUMNS) for cross-version compatibility
* Per-cart transient lock (5 min) to prevent duplicate sends
* Rate limit respected: max 10 messages per cron cycle
* Abandoned cart cron running every minute via real server cron

**Back In Stock Notifier**
* Native integration with Back In Stock Notifier for WooCommerce v7.x
* Correct hook: cwg_instock_mail_sent_success with subscriber_id (slug=instock)
* Correct BIS v7 meta keys: cwginstock_product_id, cwginstock_subscriber_phone, cwginstock_subscriber_name
* Dedicated wlp_bis_cron_hook every 5 minutes as fallback
* wlp_bis_ensure_cron() ensures scheduling via init action
* Product image sent automatically; option for fixed custom image
* Available tags: %name%, %product_name%, %product_url%
* Dedicated 🔔 Back In Stock tab in Message Logs

**Message Logs**
* Dedicated 🛒 Abandoned Carts tab with customer data, items, time since abandonment
* Dedicated 🔔 Back In Stock tab with notification history
* Locked gate when CartBounty is not installed (blurred preview + install button)
* Cart items as plain text (name + qty, comma-separated)
* Abandonment time in readable format (5 min, 2h, 3d) — red after 24h
* Manual resend button per cart
* Pagination on all tabs

**Notifications — New tabs**
* 🔔 Back In Stock tab with full message and image configuration
* Available tags card for abandoned cart (%product_name%, %cart_contents%, %cart_total%)
* %product_name% and %cart_contents% working in automated abandoned cart sends

**Mercado Pago PIX Integration**
* Automatic WhatsApp send with QR code and copy-paste code after PIX payment
* QR saved to wp-content/uploads/wlp-pix/ with auto-cleanup after 30 min
* Info card when MP plugin is not installed

**Standardized plugin badges**
* Centralized render_plugin_badge() for all integration plugins
* Active: green badge with link to plugin settings
* Inactive: yellow badge with + Install button via thickbox (WP.org)
* Applied to: CartBounty, EDD, Contact Form 7, Caldera Forms, Back In Stock

**Debug System**
* 🔍 Debug tab in Configuration with on/off toggle
* Generate diagnostic report: PHP/WP/WC/WLP versions, token, plugins, crons, CartBounty stats
* 🗑️ Clear debug log button via AJAX (bypasses Object Cache Pro)
* debug_mode correctly reports wlp_debug_enabled (not WP_DEBUG)
* Log auto-cleared when toggling debug on/off
* wlp_debug_log() at critical points: followup, BIS, rate limit, dedup
* bis_cron_hook visible in diagnostic report

**Security**
* Configurable duplicate message blocking (on/off in Configuration)
* Configurable rate limit from 1 to 100 messages per minute
* register_setting() with sanitize_callback for all floating button fields
* Logger uses fgets() line-by-line instead of file_get_contents() (large log performance)
* wp_unslash on all $_POST, nonces on all forms

**Bug Fixes**
* Fatal error WLP_Woosend_Logger::log() fixed to add()
* Fixed View subscribers link in BIS tab (edit.php?post_type=cwginstocknotifier)
* wlp_admin_notice() protected with function_exists() guard
* Version synced across WLP_VERSION, Version: header and Stable tag
* .pot regenerated with 44 strings, no fuzzy flag
* en_US translation (.po and .mo) updated

= 2.1.0 - 04/2026 =
* Transition version — see 2.7.5 for full history

= 1.5.0 - 03/2026 =
* Full plugin refactor
* HPOS, XSS, nonces and deprecated WooCommerce API fixes
* WooCommerce 8.x and WordPress 6.x compatibility
