=== Back in Stock Notifications for WooCommerce ===
Contributors: catcodestudio
Tags: woocommerce, back in stock, out of stock, waitlist, notifications
Requires at least: 6.2
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

A subscribe form on out-of-stock products and an automatic e-mail to the shopper the moment the stock is back.

== Description ==

A shopper opens a product that is out of stock and leaves. This plugin lets them leave an e-mail address instead of an empty cart — and writes to them by itself as soon as the product can be ordered again.

= Free features =

* Subscribe form on the page of any product that cannot be bought: e-mail and, optionally, a name. Logged-in customers get the fields pre-filled.
* Placement: instead of the "Out of stock" block or below it; anywhere on the page through the `[ccsn_form]` shortcode.
* Automatic e-mail as soon as the stock is back. Two independent paths trigger it: a WooCommerce event (stock edited in the admin, an order cancelled or refunded) and an hourly check that catches CSV/XML imports, ERP exchanges and direct database writes, none of which fire an event.
* The message is wrapped in the WooCommerce e-mail template — the shop's header, colours and footer.
* Subscriber list in the admin: filters by product, product ID, e-mail, status and date, pagination, and the bulk actions "send now", "put back into the waiting state" and "delete".
* Demand report — products ordered by how many people are waiting for them. The shortest possible answer to "what should I reorder first?".
* One-click unsubscribe from the e-mail and automatic clean-up of finished rows.
* Anti-spam: nonce, honeypot, submit-time trap and a per-IP hourly limit on subscriptions. The IP address is stored as a hash only.
* Optional "N shoppers are waiting for this product" counter.
* HPOS (custom order tables) and block cart/checkout compatible.

= Pro features =

* No cap on the number of active subscriptions (the free tier allows 25).
* Double opt-in confirmation of a subscription.
* Subscription to a specific product variation instead of the product as a whole.
* Custom e-mail templates with the `{product_name}`, `{product_url}`, `{price}`, `{quantity}`, `{store_name}`, `{store_url}`, `{customer_name}`, `{confirm_link}` and `{unsubscribe_link}` placeholders.
* Notifications mirrored to the shop owner in Telegram — a new subscription and a finished send batch.
* A per-run cap on the number of messages, so the send never hits the host's hourly quota.
* CSV export of the subscribers.
* Conversion statistics: how many messages went out, how many shoppers followed the link and how many of them placed an order.

A fresh install is simply the free tier — nothing Pro turns itself on. The Pro settings stay visible in their own place, greyed out and marked `Pro`, so the boundary is honest rather than hidden. A 7-day trial starts only when you ask for it: "Try Pro for 7 days" in the settings sends a real key to your e-mail and unlocks Pro right away — no card, nothing charged, one trial per install. When the trial ends the free tier keeps working with no time limit — the subscriptions already collected stay where they are and restock e-mails keep going out. Licences are annual (1 to 5 years) and include updates and support for that term.

= Requirements =

* WooCommerce 7.0 or newer
* WordPress 6.2 or newer (the plugin uses the `%i` identifier placeholder in prepared statements)
* PHP 7.4+

The plugin interface is fully translated into Ukrainian. / Інтерфейс плагіна повністю перекладено українською.

== Installation ==

1. Upload the plugin folder to `/wp-content/plugins/back-in-stock-notifications-for-woocommerce/`
2. Activate it in the "Plugins" menu
3. Go to WooCommerce → Повідомити коли з'явиться, enable subscriptions, adjust the form texts if needed and save
4. Open any out-of-stock product — the form appears on its page

== Frequently Asked Questions ==

= The form does not show up on a product =

The form is only rendered when the product really cannot be bought: out of stock, no price, or a draft. Check as well that subscriptions are enabled in the settings.

= The product was restocked by an import and no e-mail went out =

It did go out, just not instantly. An import usually fires no WooCommerce event at all, so restocks like that are picked up by the hourly check. There is no need to wait for it: the "Check now" button in the settings does the same thing immediately.

= Can the same e-mail be sent twice? =

No. A subscription moves to the "Notified" status in the same pass that sends the message, so the next check no longer sees it.

= What happens when the queue is very large? =

A single pass sends a limited number of messages (the number is configurable in Pro) and the rest follow on the next pass. That keeps the plugin from hitting the host's hourly quota.

= Does it work with variable products? =

Yes, in Pro. The shopper subscribes to the exact variation, and the form appears as soon as that variation is selected.

= Does the plugin enable Pro by itself? =

No. A fresh install is the free tier and stays that way until you click "Try Pro for 7 days" or paste a licence key. The trial issues a real key to your e-mail through catcode.com.ua, exactly like a paid one, and is available once per install.

= The licence server is unreachable — do I lose Pro? =

No. The saved key is re-checked once a day; if our server cannot be reached, the last successful verdict stays valid for another 14 days, and a network failure is never treated as "the key is bad".

= What happens to the subscriptions when the trial ends? =

Nothing is lost. The form, the subscriptions and the restock e-mails keep working; the free tier only caps how many subscriptions can be active at the same time and closes the Pro features.

= What is removed when the plugin is deleted? =

Deactivation stops the scheduled tasks but keeps the subscriber queue. Deleting the plugin drops the table and every setting.

== Screenshots ==

1. The subscribe form on an out-of-stock product page
2. Plugin settings
3. The subscriber list with its filters
4. The demand report

== Changelog ==

= 1.1.0 =
* Free is free: a fresh install no longer starts a Pro trial by itself. Pro settings stay on screen, greyed out, with a `Pro` badge and one line saying what unlocks them.
* The 7-day trial starts only on an explicit click: e-mail → a real key issued by catcode.com.ua → Pro on. One trial per install, no card involved.
* Licence keys are now verified against the licence server (activate / verify / deactivate) instead of being trusted because the field was not empty. Daily re-check, a 14-day grace window when the server is unreachable, and a "Release licence" button that frees the slot for another shop.
* The key travels in its own AJAX request, so an ordinary "Save settings" — including one submitted from a stale tab — can no longer wipe it.
* One notice instead of a recurring banner: it appears after the plugin has actually done something (a first subscription or a first restock e-mail) and never comes back once dismissed.
* Server-side Pro checks on the admin actions, so a forged request cannot use a Pro feature that the form shows as disabled.

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 1.1.0 =
The automatic 7-day trial is gone: after the update Pro is off until you start the trial yourself or activate a licence key. The free tier, the collected subscriptions and the restock e-mails are unaffected.

= 1.0.0 =
Initial release.
