=== JoeBucci Restock Alerts for WooCommerce ===
Contributors: joebucci23
Tags: woocommerce, back in stock, restock, waitlist, notify me
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 0.2.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Let shoppers subscribe to an email alert for out-of-stock products, and automatically email them the moment the product is back in stock.

== Description ==

This plugin adds a simple "Notify me when back in stock" form to any out-of-stock WooCommerce product page. Shoppers enter their email, and the plugin automatically emails everyone on the list the moment you mark the product back in stock.

Also includes a **Restock Waitlist** page under WooCommerce in wp-admin, showing you exactly which out-of-stock products have the most people waiting — real demand data for deciding what to reorder first.

**Features (v0.2.0):**

* Automatic "Notify me" form on out-of-stock product pages, with a live count of how many other shoppers are already waiting
* Works with simple and variable products — each variation is tracked and notified separately
* One email per subscriber per product — no duplicate signups
* Admin waitlist view showing pending-subscriber counts per product, plus a "Mark back in stock" one-click action that flips stock status and triggers notifications immediately
* Admin settings page to customize the email subject/body/from-name — no code required
* "Send test email to yourself" button so you can preview the exact email a subscriber would receive
* Outgoing emails are wrapped in WooCommerce's own branded email template (same look as order-confirmation emails)
* One-click, no-login unsubscribe link in every email (GDPR/CAN-SPAM friendly)
* One-click CSV export of your full waitlist
* Spam protection via an invisible honeypot field and a disposable-email-domain blocklist — no Google reCAPTCHA account or API key needed
* Fetches a fresh security nonce immediately before the subscribe form submits, so it keeps working correctly on sites using a page-caching plugin
* "My Account > Restock Waitlist" tab so logged-in customers can see and self-manage every product they're waiting on, not just via a one-off emailed link
* Optional "notify on backorder" mode for stores that sell backordered items
* Admin "Notified" history tab showing exactly who was emailed and when, in addition to the live "Pending" view
* Opt-in "delete all data on uninstall" setting (off by default, so your waitlist survives an accidental delete)
* WPML/Polylang-ready
* Lightweight — one small database table, no external services required

== Installation ==

1. Upload the plugin files to `/wp-content/plugins/joebucci-restock-alerts-for-woocommerce`, or install directly through the WordPress plugins screen.
2. Activate the plugin.
3. Make sure WooCommerce is installed and active.
4. That's it — the notify form appears automatically on any out-of-stock product page.

== Frequently Asked Questions ==

= Does this work with variable products? =

Yes — each variation is tracked separately, so a shopper is notified only when the specific variation they wanted is back in stock.

= Does this send email through my own WordPress site? =

Yes, via the standard `wp_mail()` function. For reliable delivery, we recommend using an SMTP plugin (e.g., WP Mail SMTP) rather than relying on your host's default mail setup.

= Can customers manage their own subscriptions? =

Yes — logged-in customers get a "Restock Waitlist" tab under My Account where they can see everything they're subscribed to and remove entries themselves. Guests (not logged in) still get a one-click unsubscribe link in every email.

== Changelog ==

= 0.2.0 =
* Added admin settings page for email subject/body/from-name customization.
* Added one-click, no-login unsubscribe link to every restock email.
* Added CSV export of the full waitlist from the admin page.
* Added honeypot + disposable-email-domain spam protection (no API key required).
* Fixed a class of failures where page-caching plugins serve a stale AJAX nonce, causing subscribe requests to silently fail — the subscribe form now fetches a fresh nonce immediately before submitting.
* Added WPML/Polylang compatibility (wpml-config.xml, textdomain loading).
* Redesigned the frontend notify box with a clearer, branded look.
* Fixed a real bug where the notify form and variation-level notifications didn't work correctly for variable products; subscriptions are now correctly tagged and matched per variation.
* Added a live pending-subscriber count to the frontend notify form.
* Added a "Send test email to yourself" button on the Settings page, using the currently saved template and sample data.
* Outgoing restock emails (real and test) are now wrapped in WooCommerce's own branded email template.
* Added a "Mark back in stock" action on the admin waitlist page that flips stock status and triggers notifications with one click.
* Added uninstall.php with an opt-in "delete data on uninstall" setting (defaults to keeping data).
* Added a "My Account > Restock Waitlist" tab so logged-in customers can view and remove their own subscriptions without needing the emailed unsubscribe link.
* Added an optional "notify on backorder" setting for stores that sell backordered products.
* Added an admin "Notified" history tab (up to 200 most recent) alongside the existing "Pending" view.

= 0.1.0 =
* Initial release: notify form, stock-change email trigger, admin waitlist view.
