=== Chaffery for WooCommerce ===
Contributors: chaffery
Tags: woocommerce, price alert, name your price, price drop, make an offer
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.1.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Let shoppers name the price they would pay. See that demand for every product, and win the sale when your price meets it.

== Description ==

Most visitors who like a product but not yet its price simply leave — and you never learn how close they were.

**Chaffery** gives them something to do instead: they name the price they would pay. You see those prices for each product, anonymously, and when your own price meets a shopper's price they are alerted and come back to buy **in your shop, at your checkout**. Chaffery never handles orders or payments and never changes anything in your store.

This plug-in connects your WooCommerce store to [Chaffery](https://chaffery.com/) and adds an optional **"Name your price"** button to your product pages.

= What the plug-in does =

* **Connect in two minutes** – one button opens Chaffery with your shop's address filled in. You approve a **read-only** WooCommerce key on WooCommerce's own screen; you can revoke it at any time.
* **"Name your price" button** – shown only on the products you have listed on Chaffery. Place it below the add-to-cart button, below the price, or anywhere with the `[chaffery_button]` shortcode. Supports standard WooCommerce product templates in classic and block themes. Custom templates and page builders can use the shortcode if their layout does not run the standard WooCommerce hooks. It takes the shape of your theme's own buttons — drawn as the quiet, outlined one, so "Add to cart" stays the main action.
* **Always says where things stand** – one screen shows whether the store is connected, which products are live and whether the button is showing. On a product that is not live, you (and only you) see a short note in the button's place that says why.
* **Light and private** – the button is a plain link. No JavaScript, no cookies, no tracking pixels, and nothing is loaded from Chaffery until a shopper clicks.
* **Your language** – the button speaks English, Spanish, German, French, Brazilian Portuguese or Turkish, following your shop's language, and opens Chaffery in the same language.

= How Chaffery works for a store =

1. Connect your store and choose the products you want to list.
2. Shoppers name their price for those products — on Chaffery, or through the button in your shop.
3. You see how many shoppers would buy at which price. When your price reaches a shopper's target they get an alert and buy from you as usual.

A Chaffery account is required. Listing products on Chaffery is a paid service with a free trial; see [chaffery.com](https://chaffery.com/) for current terms. The plug-in itself is free.

== External services ==

This plug-in connects your shop to **Chaffery** (https://chaffery.com), a service operated by the plug-in's author. It is needed for the plug-in's only purpose: showing the "Name your price" button on the products you have listed on Chaffery.

**What is sent, and when**

* Your site asks `https://chaffery.com/api/woo/listed` whether the store is connected and which of your products are live on Chaffery. This happens when someone who manages the shop opens **WooCommerce → Chaffery** (at most once a minute) or presses "Check connection" there, and — only while the button is switched on (it is **off** by default) — on a scheduled 15-minute background check, when the settings are saved, and when a shop manager views one of the shop's product pages (at most once a minute). Visitor page rendering does not call Chaffery. **The only data sent is your shop's address** (for example `https://example.com`). No customer data, no order data and no personal data is sent.
* When a shopper clicks the button, their browser opens `https://chaffery.com/go/woo` with your shop's address, the product's ID and a language code. This happens only after that click.
* When you press "Connect this store", your browser opens `https://sellers.chaffery.com` with your shop's address filled in. The connection itself uses WooCommerce's built-in REST API key approval screen; the read-only key is handed to Chaffery by WooCommerce, not by this plug-in.

Nothing is sent while the button is switched off and nobody opens the plug-in's screen.

Chaffery's terms and privacy policy: [Seller Terms](https://chaffery.com/en/legal/sellers) · [Terms of Service](https://chaffery.com/en/legal/terms) · [Privacy Policy](https://chaffery.com/en/legal/privacy)

== Installation ==

1. Install and activate the plug-in (WooCommerce must be active).
2. Go to **WooCommerce → Chaffery** and press **Connect this store**. Sign in to Chaffery with your e-mail address and approve the read-only key in WordPress.
3. In your Chaffery dashboard, choose the products you want to list.
4. Back in **WooCommerce → Chaffery**, switch on **Show the button on product pages** and press **Save changes**.

== Frequently Asked Questions ==

= Does Chaffery change prices, products or orders in my store? =

No. The WooCommerce key is read-only. Chaffery reads product names, descriptions, photos, prices and stock. Purchases always happen in your shop.

= Where does the button appear? =

Only on products that are live on Chaffery, in the position you choose. Products you have not listed show no button. While the button is on, WordPress schedules a background check every 15 minutes; when it actually runs depends on your site's WordPress cron setup and traffic. Opening WooCommerce → Chaffery or a product page as a shop manager also checks for changes, at most once a minute. Use **Check connection** or **Check again** on the settings screen to request a fresh check. Page caching can delay a visible change; clear your page cache if needed.

= I switched the button on, but I do not see it. =

The button needs three things: the store is connected, the product is live on Chaffery, and the button is switched on. **WooCommerce → Chaffery** shows the connection, live products and button settings. With an automatic position selected, shop managers see a short note in the button's place when a product is not live or the store is not connected; visitors never see that note. If you selected the manual position, place `[chaffery_button]` in your product template, or use `[chaffery_button id="123"]` with the product's ID on another page. If you use a page cache, clear it after changing the button settings.

= What are the notes on my product pages? Can visitors see them? =

No. They are shown only to signed-in users who manage the shop, and only while the button is switched on. To switch them off: `add_filter( 'chaffery_wc_manager_note', '__return_false' );`

= Does the plug-in slow down my shop? =

Visitors' product pages use the list of live products stored in your database and never wait for a Chaffery request. While the button is enabled, a shop manager's product-page visit can refresh that list at most once a minute and wait for the response, using a six-second request timeout. The button itself is a link with a few lines of CSS.

= Does it add cookies or tracking? =

No. The plug-in sets no cookies and loads no scripts in your shop. (The settings screen in your dashboard uses a few lines of script for convenience.)

= Can I change the button text? =

Yes, under WooCommerce → Chaffery. Developers can also filter the line under the button with `chaffery_wc_button_hint`.

= What happens when I deactivate or delete the plug-in? =

Deactivating stops the background check. Deleting removes the plug-in's two options from your database. Your Chaffery account is not affected; disconnect the store in your Chaffery dashboard or revoke the key under WooCommerce → Settings → Advanced → REST API.

== Screenshots ==

1. WooCommerce → Chaffery: the connection, the live products and the button on one screen.
2. The "Name your price" button on a product page.

== Changelog ==

= 1.1.1 =
* Preserve unsaved settings when returning from Chaffery.
* Keep the latest valid connection state when refreshes overlap or a service response is incomplete.
* Clean up each site's settings when uninstalling on a multisite network.
* Clarify refresh timing and custom product template setup.

= 1.1.0 =
* New settings screen: connection, live products and the button's state on one page, with the next step always in view. The connection is checked when the screen opens.
* "Settings saved" and "Checked" confirmations.
* The button is placed reliably in classic themes, block themes (both add-to-cart blocks), page builders and `[product_page]`; it also appears on products that are out of stock.
* The button takes the theme's button shape and is drawn as the secondary, outlined action.
* Shop managers see a note in the button's place on products that are not live, saying why.
* Newly listed products show their button at once for shop managers; page caches are told when a product's button appears or disappears.
* Button texts in Spanish, German, French, Brazilian Portuguese and Turkish.
* Shop managers (not only administrators) can save the settings.

= 1.0.0 =
* First release: connect a store, "Name your price" button for classic and block themes, shortcode.

== Upgrade Notice ==

= 1.1.1 =
Preserves unsaved settings and the latest valid connection state; improves multisite cleanup.

= 1.1.0 =
Clearer settings screen, more reliable button placement, and notes that explain why a button is not showing.
