=== Demfilz Back in Stock Notifications for WooCommerce ===
Contributors: demfilz
Tags: back in stock, stock notification, waitlist, out of stock, restock alert
Requires at least: 6.2
Tested up to: 7.1
Stable tag: 1.0.0
Requires PHP: 7.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Email shoppers the moment a sold out product or variation is back in stock. Waiting lists, double opt-in, a My Account tab and privacy tools.

== Description ==

A sold out product is a lost sale unless you can bring the shopper back. This plugin puts a small "Email me when it is back in stock" form on every sold out product and variation, keeps the waiting list for you, and emails everyone on it automatically when stock returns.

**For shoppers**

* A one-field form on sold out products: email address and a button. Logged in customers have their address filled in.
* Works per variation: choose "Blue, Large" and the form appears when that option is sold out, so the alert is for exactly what they wanted.
* Optional consent checkbox with your own wording and a link to your privacy policy.
* Optional double opt-in for guests: one click on a confirmation email puts them on the list.
* A "Stock alerts" tab in My Account where customers see what they are waiting on and can remove a request.
* Every alert carries a one-click "remove me" link.
* The form works without JavaScript.

**For the store**

* Alerts go out on their own as soon as the stock status changes to in stock, whether you edit the product, import a CSV, restock through the REST API or an order is cancelled and the stock comes back.
* Each person gets one email per request, and stock is checked again right before sending, so a restock that was entered by mistake and corrected straight away sends nothing. An optional delay adds extra margin.
* Big lists go out in background batches, so a popular product does not time out the page that restocked it.
* WooCommerce > Stock Alerts: every request with its status (waiting, unconfirmed, notified, cancelled), search by email or product, filters, bulk cancel, reactivate and delete, a "send now" per request, and a CSV export.
* A "Most wanted" tab ranks sold out products by the number of people waiting, so you know what to reorder first, with a "Notify now" button for products already back in stock.
* A box on the product editor shows how many people are waiting, by variation.
* Add a subscriber by hand for requests that arrive by phone or email.
* Both emails are standard WooCommerce emails: edit the subject, heading and extra text under WooCommerce > Settings > Emails, preview them, and override the templates in your theme.
* Treat products on backorder as sold out, or not, as you prefer.
* Old sent alerts are tidied away after a number of days you choose.

**Privacy and safety**

* Personal data exporter and eraser for the waiting list, and suggested privacy policy text.
* Requests are rate limited per visitor, a honeypot field catches bots, and every form carries a nonce.
* No external services. Nothing leaves your site except the emails your store sends.
* Compatible with WooCommerce High-Performance Order Storage (HPOS) and the cart and checkout blocks.

**For developers**

Shortcode: `[dbis_form]` on a product page, or `[dbis_form product="123"]` anywhere.

Actions: `dbis_subscribed`, `dbis_confirmed`, `dbis_unsubscribed`, `dbis_alert_sent`.
Filters: `dbis_wants_alerts`, `dbis_product_types`, `dbis_form_html`, `dbis_requires_confirmation`, `dbis_account_endpoint`, `dbis_max_requests`, `dbis_limiter_ip`.

== Installation ==

1. Install and activate the plugin. WooCommerce must be active.
2. Open a sold out product: the form is there already.
3. Go to WooCommerce > Stock Alerts > Settings to change the wording, the position of the form, double opt-in and the consent box.
4. Edit the email text under WooCommerce > Settings > Emails > Back in stock.

== Frequently Asked Questions ==

= When exactly is an alert sent? =

When a product's stock status changes to "In stock" (or to "On backorder", unless you treat backorders as sold out). That covers editing the product, quick edit, CSV import, the REST API, and stock returned by a cancelled or refunded order. The plugin checks the stock again at the moment of sending, so a restock that is reverted straight away sends nothing.

= Does it work with variable products? =

Yes. With the default position the form appears under the "Out of stock" text of the chosen variation, and the alert is for that variation only. If the whole product is sold out, customers can also ask to be told when any option is back.

= Can shoppers subscribe without an account? =

Yes, unless you switch guests off in the settings, in which case the form asks them to log in. Guests can also be asked to confirm by email (double opt-in).

= What if hundreds of people are waiting? =

The alerts are sent in background batches (50 at a time by default, one minute apart) through WooCommerce's Action Scheduler, so the page that restocked the product does not wait for them.

= Can I send the alerts myself? =

Yes. The Most wanted tab has a "Notify now" button for products that are back in stock, and each request has a "Send alert now" action.

= Where do I change the email text? =

WooCommerce > Settings > Emails > "Back in stock" and "Confirm back in stock alert". The templates can be overridden in your theme like any WooCommerce email.

= Does it support the block-based product editor and block themes? =

The form appears in classic product templates, in the Add to Cart with Options block, and wherever you place the shortcode. The My Account tab works with block and classic themes.

= Is any data sent anywhere? =

No. The waiting list lives in your own database and the only thing sent is the emails your store sends.

== Screenshots ==

1. The form on a sold out product.
2. The form for a sold out variation.
3. WooCommerce > Stock Alerts: the subscriber list.
4. The Most wanted tab.
5. The back in stock email.
6. The Stock alerts tab in My Account.
7. Settings.

== Changelog ==

= 1.0.0 =
* First release.

== Upgrade Notice ==

= 1.0.0 =
First release.
