# etechflow/module-back-in-stock-notification

> Back-in-stock notification for Magento 2. Customer subscribes on out-of-stock product pages, gets emailed when stock returns. Anonymous + customer-linked subscriptions, multi-store aware, one-click unsubscribe, queued/rate-limited delivery. Standalone — works without any other ETechFlow module — and integrates richer when paired with NDE / BED / ISP.

`composer require etechflow/module-back-in-stock-notification`

Canonical URL: https://packagento.com/etechflow/module-back-in-stock-notification

## At a glance

- **Vendor**: etechflow (https://packagento.com/etechflow.md)
- **Latest version**: 1.3.1 — released 2026-06-22
- **Pricing**: Free
- **Package type**: Magento 2 module
- **Status**: active, accepting new buyers

## Installation

Packagento is licence-gated, so even free packages need a licence on a project before Composer can resolve them.

1. **Sign in or create an account** at https://packagento.com/customer/account/.

2. **Add the package to your account.** Open https://packagento.com/etechflow/module-back-in-stock-notification and complete the free checkout. A licence is minted automatically.

3. **Create or pick a project, then activate the licence on it.**
   - Projects represent the Magento installs you deploy to. Manage them at https://packagento.com/projects/.
   - Activate the new licence on the project you'll deploy this package to. Activation is what generates the Composer credentials scoped to that project.

4. **Add the project credentials to your Magento codebase.**

   Grab the project's public + private key from https://packagento.com/projects/ (open the project, then its Credentials tab), and add them to `auth.json`:

   ```json
   {
     "http-basic": {
       "packagento.com": {
         "username": "ppk_live_...",
         "password": "psk_live_..."
       }
     }
   }
   ```

   Add the Packagento Composer repository to `composer.json`:

   ```json
   {
     "repositories": [
       { "type": "composer", "url": "https://packagento.com" }
     ]
   }
   ```

5. **Install and apply.**

   ```bash
   composer require etechflow/module-back-in-stock-notification:*
   bin/magento setup:upgrade
   bin/magento setup:di:compile
   bin/magento cache:flush
   ```

## What it does

Back-in-stock notification for Magento 2. Customer subscribes on out-of-stock product pages, gets emailed when stock returns. Anonymous + customer-linked subscriptions, multi-store aware, one-click unsubscribe, queued/rate-limited delivery. Standalone — works without any other ETechFlow module — and integrates richer when paired with NDE / BED / ISP.

## README

Customers subscribe to out-of-stock products. When stock returns, they get an email.

Standalone-first — works on any Magento 2.4.4+ install without other ETechFlow modules. Integrates richer when paired with NDE / BED / ISP.

### Install

```bash
composer require etechflow/module-back-in-stock-notification:^1.0
bin/magento module:enable ETechFlow_BackInStockNotification
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:flush
## Restart php-fpm to clear OPcache (mandatory on prod with opcache.validate_timestamps=0)
```

### Activate the licence

```bash
php tools/generate-license.php --module=back-in-stock-notification --host=<your-domain>
```

Paste the key into **Stores → Configuration → eTechFlow → Back-in-Stock Notification → License Key**.

For multi-module customers, paste the bundle key into the **Bundle License Key** field instead. One key activates every ETechFlow module installed on the host.

### Verify

```bash
bin/magento etechflow:bisn:verify
```

Twelve PASS lines means you're good to go.

### How it works

1. **Customer hits an out-of-stock PDP** → a "Notify me when back in stock" form replaces the disabled Add-to-Cart button.
2. **Form submit** → `etechflow_bisn_subscription` row created. Anonymous (email only) or customer-linked.
3. **Merchant saves stock with qty > 0** → `StockSaveObserver` enqueues a notification for every subscription matching that product + store.
4. **Cron runs every 5 min** → `QueueConsumer` sends batched, rate-limited emails. Default 60 emails/minute.
5. **Customer clicks the email** → one-click unsubscribe (RFC 8058 compliant) OR goes to the PDP to purchase.

### Configuration

`Stores → Configuration → eTechFlow → Back-in-Stock Notification`:

- **License Key** — per-module key (or use Bundle License Key for the suite)
- **Module Enabled** — toggle the whole feature
- **Email Rate Limit** — emails/minute (default 60). Adjust to your SMTP capacity.
- **Subscription Lifetime** — auto-expire unredeemed subscriptions after N days (default 180, 0 = never)
- **eTechFlow Suite Integrations** — NDE / BED / ISP opt-in toggles (hidden if the sibling module isn't installed)
- **Notifications** — sender email, sender name, email subject template

### Compatibility

- Magento Open Source 2.4.4 – 2.4.8
- Adobe Commerce 2.4.4 – 2.4.8
- PHP 8.1 / 8.2 / 8.3 / 8.4
- Hyvä Theme + Hyvä Checkout (PDP form renders via Hyvä-safe block)

### Support

info@etechflow.com — please include your license key + Magento version when reporting issues.

## Changelog

All notable changes to this module. Adheres to [Semantic Versioning](https://semver.org/).

---

### [1.0.3] — 2026-05-22 — Move admin menu under eTechFlow top-level sidebar

#### Changed

- **BISN admin pages relocated to a dedicated "eTechFlow" sidebar entry.** Previously the Subscriptions list lived under `Sales → Operations`. Now it sits in a `Back-in-Stock` column inside a new top-level `eTechFlow` sidebar entry (clusters with other paid-extension vendors above Magento's Stores). Matches the pattern Amasty / Magefan / MageWorx use so merchants can spot paid extensions at a glance.
- Each eTechFlow module declares the same `eTechFlow::root` + `eTechFlow::settings` + `eTechFlow::configuration` entries — Magento merges by id, so installing N modules still produces exactly one `eTechFlow` sidebar group. No inter-module dependency added; BISN remains standalone.

#### Migration

```
composer update etechflow/module-back-in-stock-notification
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento setup:static-content:deploy -f
bin/magento cache:flush
```

Admin URL routes unchanged (`etechflow_bisn/subscription/index` still works). No schema or behaviour changes — pure menu-layout adjustment.

---

### [1.0.2] — 2026-05-20 — Inline-AJAX subscribe (progressive enhancement)

Removes the full-page reload on subscribe. Customer types email, clicks Notify me, the form swaps inline to a "You're on the list" success card. No spinner, no flash-message round-trip.

#### Added

- **Inline-AJAX submit via vanilla `fetch()`** — no jQuery, no Alpine, no Magewire dependency. Works on every browser Magento officially supports (Safari 11+, Chrome / Edge / Firefox last 2 versions).
- **Form `data-element` hooks** on the wrapper + form so the script binds reliably without conflicting with anything else on the page.
- **Inline-error rendering** — invalid email / form-key expired / dedupe message all render inline next to the form, not as a flash message.

#### Changed

- **`Controller/Subscription/Create.php` is now dual-mode**: when the request includes `X-Requested-With: XMLHttpRequest` or `Accept: application/json`, returns a JSON envelope (`{success, message}`). Otherwise falls back to the v1.0.1 flash-message + redirect-to-referrer flow. Same persistence + dedupe + double-opt-in logic, only the response shape differs.

#### Backwards compatibility

- **JavaScript disabled** → plain HTML POST + redirect still works (the `<form>` still has `action` + `method="post"`).
- **AJAX endpoint** is the same URL — no new routes, no extra controllers, no breaking changes for anyone who built integrations against v1.0.0/1.0.1's URL.
- No new DB schema, no new admin config, no new dependencies. Drop-in replacement.

#### Theme compatibility

- **Luma**: native browser `fetch()` available — works.
- **Hyvä Theme**: `fetch()` available — works. Inline JS doesn't conflict with Alpine or Hyvä's own scripts.
- **Hyvä Checkout**: BISN's form is on the PDP, not the checkout, so this is irrelevant — but the same form works if a Hyvä Checkout merchant decides to display it inside the checkout for any reason.

#### Migration

```
composer update etechflow/module-back-in-stock-notification
bin/magento cache:flush
```

No `setup:upgrade`, no `setup:di:compile` needed — only template + controller changed, no schema or DI tree changes. Customers upgrading from v1.0.1 just need to flush cache.

---

### [1.0.1] — 2026-05-20 — Real-install hotfix (3 bugs caught by live Magento 2.4.8 test)

Caught the moment we ran this module against a real Magento install for the first time. None of these would have shown up in `php -l` / composer-resolution / XSD-validation — only `setup:upgrade` and a full end-to-end run surface them.

#### Fixed

_(Changelog truncated for .md surface. Full history on https://packagento.com/etechflow/module-back-in-stock-notification.)_

## Recent Versions

| Version | Released |
|---|---|
| 1.3.1 | 2026-06-22 |
| 1.3.0 | 2026-06-20 |
| 1.2.0 | 2026-06-06 |
| 1.1.0 | 2026-06-01 |
| 1.0.3 | 2026-05-22 |
| 1.0.2 | 2026-05-20 |
| 1.0.1 | 2026-05-20 |
| 1.0.0 | 2026-05-20 |

## Dependencies

### Require

| Package | Constraint |
|---|---|
| magento/framework | ^103.0\|\|^104.0 |
| magento/module-backend | ^102.0\|\|^103.0 |
| magento/module-catalog | ^104.0\|\|^105.0 |
| magento/module-catalog-inventory | ^100.4\|\|^101.0 |
| magento/module-config | ^101.2\|\|^102.0 |
| magento/module-cron | ^100.4\|\|^101.0 |
| magento/module-customer | ^103.0\|\|^104.0 |
| magento/module-email | ^101.1\|\|^102.0 |
| magento/module-store | ^101.1\|\|^102.0 |
| magento/module-ui | ^101.2\|\|^102.0 |
| php | ~8.1.0\|\|~8.2.0\|\|~8.3.0\|\|~8.4.0 |

### Suggest

| Package | Constraint |
|---|---|
| etechflow/module-backorder-eta-display | Optional. When installed, restock-on-backorder notifications include BED's per-product ETA. |
| etechflow/module-in-store-pickup | Optional. When installed, customers can subscribe to a specific pickup-store's stock. |
| etechflow/module-next-day-eligibility | Optional. When installed, 'back in stock' uses NDE's eligibility rules engine. |

## Quality

Latest release (1.3.1) fails the Packagento QA pipeline. Verdicts below are per-cell (Magento line × PHP version) for the matrixed tools, and run-once for the static / security tiers.


### Compatibility

Each Magento line is installed on its supported PHP versions, then the module is built (DI compile + static-content deploy). Cells show passed / failed / untested; staircase gaps render as `–`.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | Pass | Pass | – | – |
| 2.4.8 | – | Pass | Pass | – |
| 2.4.9 | – | – | Pass | not tested |


### Code Quality

Advisory checks against the module's source. Never affect the Compatibility verdict — a phpcs finding can't make a module incompatible.

#### Static Analysis

Coding standards (phpcs), mess detection (phpmd), copy-pasted code (cpd), PHP cross-version compatibility, composer.json validity. Each runs once for the whole module.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| PHPCS | Fail | 309 | 8 errors, 301 warnings (ruleset: Magento2) — 203 auto-fixable with phpcbf |
| PHPMD | Warning | 40 | 40 rule violations (CyclomaticComplexity:7, NPathComplexity:7, EmptyCatchBlock:7, UnusedFormalParameter:6, MissingImport:5) |
| Cpd | Warning | 1 | 1 duplicated chunk spanning 29 total lines (min-lines=5, min-tokens=70) |
| Composer validate | Info | 1 | valid; 1 advisory note (composer validate --strict) |

#### PHPStan

Type-checks the module against a real Magento install. Re-runs per Magento + PHP version because resolvable symbols differ between releases.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | 27 | 27 | – | – |
| 2.4.8 | – | 27 | 27 | – |
| 2.4.9 | – | – | 27 | N/A |


### Tests

Unit and integration suites run per Magento + PHP cell. Test failures speak to the module's behaviour, not its compatibility with a line, so they're reported here separately.

#### Unit Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |

#### Integration Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |


### Security

Dependency-advisory audit (composer audit) plus a source malware scan. A malware detection fails the version outright.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| Composer audit | Pass | 0 |  |
| Malware scan | Pass | 0 |  |

## Licence and pricing

Free. A licence is still minted on checkout and bound to your project for Composer access — no payment step.

Refundable within 14 days of first purchase via https://packagento.com/account/refunds/.

## Install via Claude Code or any MCP client

The Packagento MCP server can run the licence + project + Composer steps above in one tool call:

```
purchase_and_install_packages(
  composer_names=["etechflow/module-back-in-stock-notification"],
  project_id="proj_xxx"
)
```

This handles cart, checkout, licence minting, project activation, and writes auth.json credentials. Connect a client with `claude mcp add packagento https://mcp.packagento.com`. Full setup at https://packagento.com/docs/mcp-setup.

## Vendor

etechflow is a Magento 2 vendor on Packagento. See https://packagento.com/etechflow.md for their full catalogue.

