# storetown-media/module-b2b-register

> B2B customer registration with admin approval workflow for Magento 2 / Adobe Commerce. Adds a dedicated B2B signup form with company data, VAT ID, and reCAPTCHA, holds new accounts in a pending state until a store admin reviews them, and triggers separate transactional emails for the customer and the shop owner.

`composer require storetown-media/module-b2b-register`

Canonical URL: https://packagento.com/storetown-media/module-b2b-register

## At a glance

- **Vendor**: Storetown Media (https://packagento.com/storetown-media.md)
- **Latest version**: v1.3.3 — released 2026-08-23
- **Pricing**: $99.00/year, subscription
- **Package type**: Magento 2 module
- **Status**: active, accepting new buyers

## Installation

This is a paid package. The Packagento install flow is licence-gated, so a Composer install needs a licence + project + project credentials in place first.

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

2. **Purchase the package.** Open https://packagento.com/storetown-media/module-b2b-register, add it to your cart, and complete checkout. A licence is minted automatically once payment clears.

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 storetown-media/module-b2b-register:*
   bin/magento setup:upgrade
   bin/magento setup:di:compile
   bin/magento cache:flush
   ```

## What it does

B2B customer registration with admin approval workflow for Magento 2 / Adobe Commerce. Adds a dedicated B2B signup form with company data, VAT ID, and reCAPTCHA, holds new accounts in a pending state until a store admin reviews them, and triggers separate transactional emails for the customer and the shop owner.

## README

B2B customer registration with admin approval workflow for Magento 2 / Adobe Commerce.

### Features

- **B2B Registration Form** - Dedicated registration page with company details, contact person, address, and optional fields (VAT ID, customer number, salutation)
- **Admin Approval Workflow** - New B2B customers are set to "Pending" status and must be approved or rejected by an admin before they can log in
- **Customer Grid Integration** - B2B Status and Company columns in the customer grid with filter and sort support
- **Mass Actions** - Bulk approve/reject B2B customers directly from the customer grid
- **Email Notifications** - Configurable approval, rejection, and admin notification emails
- **Google reCAPTCHA v2** - Optional spam protection for the registration form
- **Registration Modes** - Hybrid (B2B + B2C), B2B Only, or B2C Only with automatic redirects and link banners
- **Customizable Form Design** - Primary and secondary color picker in admin configuration
- **Field Visibility Control** - Configure which fields are shown (hidden, optional, or required) per store view
- **Fully Translatable** - English as primary language with German translation included (`de_DE.csv`)

### Requirements

- Magento Open Source 2.4.x or Adobe Commerce 2.4.x
- PHP 8.1, 8.2, 8.3 or 8.4

### Installation

#### Via Composer (recommended)

```bash
composer require storetown-media/module-b2b-register
bin/magento module:enable STM_B2bRegister
bin/magento setup:upgrade
bin/magento cache:flush
```

#### Manual Installation

1. Create the directory `app/code/STM/B2bRegister/`
2. Copy all module files into this directory
3. Run:

```bash
bin/magento module:enable STM_B2bRegister
bin/magento setup:upgrade
bin/magento cache:flush
```

### Configuration

Navigate to **Stores > Configuration > STM > B2B Register** in the Magento Admin.

#### General Settings

| Setting | Description |
|---|---|
| Module Enabled | Enable or disable B2B registration |
| Page Title | Title of the registration page |
| Default Customer Group (Pending) | Customer group assigned before approval |
| Customer Group After Approval | Customer group assigned after approval (empty = manual) |
| Pre-selected Country | Default country in the registration form |
| Registration Mode | Hybrid, B2B Only, or B2C Only |

#### Form Settings

| Setting | Description |
|---|---|
| Show Tax Number/VAT ID | Hidden, Visible (optional), or Visible (required) |
| Show Customer Number | Hidden, Visible (optional), or Visible (required) |
| Show Salutation | Hidden, Visible (optional), or Visible (required) |
| Show Newsletter Checkbox | Yes/No |
| Terms CMS Page | CMS page for terms link |

#### Email Settings

| Setting | Description |
|---|---|
| Send Approval Email | Notify customer on approval |
| Send Rejection Email | Notify customer on rejection |
| Email Sender | Store identity used as sender |
| Admin Notification | Notify admin on new registration |
| Admin Email Address | Recipient for admin notifications |

#### Form Design

| Setting | Description |
|---|---|
| Primary Color | Headings, buttons, borders |
| Secondary Color | Button hover, accents |

#### Google reCAPTCHA

| Setting | Description |
|---|---|
| Enable reCAPTCHA | Show reCAPTCHA v2 checkbox |
| Site Key | Google reCAPTCHA v2 public key |
| Secret Key | Google reCAPTCHA v2 private key |

### Approval Workflow

1. Customer fills out the B2B registration form
2. Account is created with **Pending** status
3. Admin receives email notification (if enabled)
4. Customer cannot log in while status is Pending
5. Admin approves or rejects via:
   - **Customer Edit Page** - Approve/Reject buttons
   - **Customer Grid** - Mass actions for bulk operations
6. Customer receives approval/rejection email (if enabled)
7. On approval, customer group is updated automatically (if configured)

### Events

The extension dispatches the following events for third-party integrations:

| Event | When |
|---|---|
| `stm_b2b_registration_before` | Before customer account creation |
| `stm_b2b_registration_after` | After successful registration (includes B2B data) |
| `customer_register_success` | Standard Magento event for compatibility |
| `stm_b2b_newsletter_subscribe` | When newsletter subscription is selected |
| `stm_b2b_customer_approved` | When a B2B customer is approved |
| `stm_b2b_customer_rejected` | When a B2B customer is rejected |

### Translation

The extension uses English as the primary language. A German translation is included in `i18n/de_DE.csv`.

To add additional translations, create the corresponding CSV file in `i18n/` (e.g., `i18n/fr_FR.csv`).

### Running Tests

```bash
cd /path/to/magento
vendor/bin/phpunit -c app/code/STM/B2bRegister/phpunit.xml.dist
```

### Code Quality

```bash
vendor/bin/phpcs --standard=Magento2 app/code/STM/B2bRegister/
```

The extension passes PHPCS Magento2 standard with 0 errors and 0 warnings (using the included `phpcs.xml`).

### File Structure

```
STM/B2bRegister/
├── Api/                          # Service contracts
├── Block/                        # Frontend and admin blocks
├── Controller/                   # Frontend and admin controllers
├── Model/                        # Business logic, config, email
├── Plugin/                       # Login blocking, redirect, welcome email
├── Setup/Patch/Data/             # Data patches for customer attributes
├── Test/Unit/                    # PHPUnit test suite (97 tests)
├── Ui/Component/                 # Admin grid columns and form modifier
├── etc/                          # Module config, DI, routes, system.xml
├── i18n/                         # Translation files
├── view/frontend/                # Frontend templates, layouts, emails
├── view/adminhtml/               # Admin templates, UI components
├── composer.json
├── phpcs.xml
├── phpunit.xml.dist
└── registration.php
```

### Support

_(README truncated for .md surface. Full README on https://packagento.com/storetown-media/module-b2b-register.)_

## Changelog

All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/).

### [1.0.0] - 2026-04-24

Initial public release on the Adobe Commerce Marketplace.

#### Added
- Dedicated B2B registration page (`/b2bregister/account/create`) capturing
  company name, VAT ID / tax number, customer number, salutation, contact
  person, delivery address and phone number.
- Admin approval workflow: new accounts are placed in a configurable pending
  customer group and blocked from login until an admin approves or rejects
  them via the customer edit page or the customer grid mass actions.
- Customer grid integration with filterable and sortable **B2B Status** and
  **Company** columns, and the **B2B Approve** / **B2B Reject** mass actions.
- Four transactional email templates (registration confirmation, admin
  notification, approval, rejection), all editable under
  *Marketing > Email Templates*.
- Six configuration groups under *Stores > Configuration > STM > B2B Register*,
  scope-aware down to the store view: General, Form, Form Design, Email,
  Notice Texts and Google reCAPTCHA v2.
- Three registration modes: *Hybrid* (B2B + B2C with cross-links),
  *B2B Only* (standard registration redirected to B2B) and *B2C Only*
  (module installed but hybrid banner suppressed).
- Field visibility control (hidden / optional / required) for VAT ID,
  customer number and salutation, per store view.
- `STM\B2bRegister\Api\B2bRegistrationInterface` service contract with
  `approve()`, `reject()` and `getStatus()` methods.
- Dispatched events for CRM and marketing-automation integrations:
  `stm_b2b_registration_before`, `stm_b2b_registration_after`,
  `stm_b2b_customer_approved`, `stm_b2b_customer_rejected`,
  `stm_b2b_newsletter_subscribe`. The standard Magento
  `customer_register_success` event is dispatched for compatibility.
- English source language with German translation (`i18n/de_DE.csv`).
- Hyvä Theme and Luma-based theme compatibility (no JavaScript framework
  dependency on the frontend).

#### Compatibility
- Magento Open Source 2.4.x and Adobe Commerce 2.4.x
- PHP 8.1, 8.2, 8.3 and 8.4

## Recent Versions

| Version | Released |
|---|---|
| v1.3.3 | 2026-08-23 |

## Dependencies

### Require

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

## Quality

Latest release (v1.3.3) 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 | Pass | 0 |  |
| PHPMD | Warning | 84 | 84 rule violations (UnusedPrivateField:84) |
| Cpd | Warning | 2 | 2 duplicated chunks spanning 112 total lines (min-lines=5, min-tokens=70) |
| Composer validate | Pass | 0 |  |

#### 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 | 17 | 17 | – | – |
| 2.4.8 | – | 17 | 17 | – |
| 2.4.9 | – | – | 17 | 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

Subscription — $99.00/year, auto-renews until cancelled. Includes all minor + patch upgrades within the licensed major. One licence per project; cancelling stops auto-renewal but the existing licence keeps working until its end date.

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=["storetown-media/module-b2b-register"],
  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

Storetown Media is a Magento 2 vendor on Packagento. See https://packagento.com/storetown-media.md for their full catalogue.

