# yireo/magento2-salesblock2

> Block transactions based on various rules

`composer require yireo/magento2-salesblock2`

Canonical URL: https://packagento.com/yireo/magento2-salesblock2

## At a glance

- **Vendor**: yireo (https://packagento.com/yireo.md)
- **Latest version**: 2.2.7 — released 2025-10-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/yireo/magento2-salesblock2 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 yireo/magento2-salesblock2:*
   bin/magento setup:upgrade
   bin/magento setup:di:compile
   bin/magento cache:flush
   ```

## What it does

Block transactions based on various rules

## README

Prevent Magento 2 orders from being placed, based on specific rules.

Also see [yireo.com/software/magento-extensions/salesblock2](https://www.yireo.com/software/magento-extensions/salesblock2)

### Installation 
To install this module, use composer:
```bash
composer require yireo/magento2-salesblock2
```

Afterwards, enable the module and run the setup upgrade, to make sure the database table is properly created:
```bash
bin/magento module:enable Yireo_SalesBlock2
bin/magento setup:upgrade
```

Next, install (and enable) one or more of the additional plugins. Without these plugins, the SalesBlock2 extension will not work:

- [github.com/yireo/Yireo_SalesBlock2ByIp](https://github.com/yireo/Yireo_SalesBlock2ByIp)
- [github.com/yireo/Yireo_SalesBlock2ByEmail](https://github.com/yireo/Yireo_SalesBlock2ByEmail)
- [github.com/yireo/Yireo_SalesBlock2ByGeo](https://github.com/yireo/Yireo_SalesBlock2ByGeo) (also requires the PHP GeoIP module)

### Usage
Navigate in the Magento Admin Panel to the Store Configuration to enable this module. Then, navigate in the Magento Admin Panel to **Sales > Sales Block Rules** to configure a rule. A rule consists of the following parts:

- **Enable**: Yes or no.
- **Label**: For managing things in your backend.
- **Conditions**: One or more conditions that **all** need to be met, before the rule is a match. The conditions are activated only through additional modules (see above). For instance, you could say that you are blocking sales for a person, coming from a certain IP range **and** using a specific email address.
- **Frontend label**: The message to display to the blocked customer on the frontend.
- **Frontend text**: An additional explanation to display to the blocked customer.

For additional details, see the READMEs of all submodules.

## Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### [Unreleased]

### [2.2.7] - 22 October 2025
#### Fixed
- Change virtual type ending with Logger to prevent DI debug message
- PHP 8.4 compat
- Fix issue with rule not found by any matcher

### [2.2.6] - 14 August 2025
#### Fixed
- Better fix

### [2.2.5] - 14 August 2025
#### Fixed
- PHP 8.4 compat

### [2.2.4] - 11 April 2024
#### Fixed
- Removed helper

### [2.2.3] - 11 April 2024
#### Fixed
- Bug when no rules are matched by any matcher

### [2.2.2] - 9 April 2024
#### Fixed
- Compat psr/log with Magento 2.4.7
- Rename Match/ folder to RuleMatch/ for PHP 8.2 compat

### [2.2.1] - 8 April 2028
- Failed release

### [2.2.0] - 16 April 2022
#### Fixed
- PHP 8 compatibility (and therefore Magento 2.4.4)

### [2.1.5] - 16 March 2022
#### Fixed
- Converted InstallSchema into DB schema XML

#### Removed
- Remove deprecated unit tests

### [2.1.4] - 10 March 2022
#### Removed
- Removed unneeded module version
- Remove button dep with CMS module

### [2.1.3] - 9 March 2022
#### Fixed
- Fix broken namespace
>>>>>>> bd20f5d4773b621e93f13932581e6b2fc85fb677

### [2.1.2] - 2 March 2022
#### Fixed
- Remove dep with SalesBlock2ByEmail module

### [2.1.1] - 2 March 2022
#### Fixed
- Remove PHP dep from composer
- Add required utility to core package

### [2.1.0] - 18 February 2021
#### Fixed
- Code compliance with Magento PHPCS
- Fixed issue with Guest Checkout email not being properly picked up

#### Added
- Added additional event observer to guarantee blocking of guest orders
- Debugging with `var/log/yireo_salesblock.log` file

### [2.0.4] - 24 November 2020
#### Fixed
- Issue when checkout is accessed directly
- Removed deprecated observer
- Set items_count to 0 as well to force "no-items" in cart

### [2.0.3] - 29 July 2020
#### Added
- Magento 2.4 compatibility

### [2.0.2] - 15 July 2019
#### Added
- `config.xml` with default settings
- Handy methods in rule repository
- Strict typing in rule repository and interface
- Integration test for rule repository
- Integration test for rule helper with simulation of IP and email matching

### [2.0.1] - 4 July 2019
#### Added
- Add KeepAChangeLog support
- Move configuration to separate **Yireo** section

### [2.0.0] - November 2018
#### Added
- Magento 2.3 compatibility
- Major rewrite to decouple rules from main module

### [1.0.1] - August 2018
#### Added
- Create separate Configuration class instead of using Helper
- Add message in grid when module is disabled through setting

### [1.0.0] - August 2018
#### Added
- Public release
- Composer support

### [0.0.3] - June 2019
#### Added
- Beta testing on limited sites
- Improved exception handling

### [0.0.2] - November 2017
#### Added
- Main migration of functionality
- Setup UiComponents
- Basic Integration Tests

### [0.0.1] - September 2017
#### Added
- First draft

## Recent Versions

| Version | Released |
|---|---|
| 2.2.7 | 2025-10-22 |
| 2.2.6 | 2025-08-14 |
| 2.2.5 | 2025-08-14 |
| 2.2.4 | 2024-04-11 |
| 2.2.3 | 2024-04-11 |
| 2.2.2 | 2024-04-09 |
| 2.2.1 | 2024-04-08 |
| 2.2.0 | 2022-04-16 |
| 2.1.5 | 2022-03-16 |
| 2.1.4 | 2022-03-10 |

Showing 10 of 20 versions. Full release history on https://packagento.com/yireo/magento2-salesblock2.

## Dependencies

### Require

| Package | Constraint |
|---|---|
| ext-json | * |
| ext-pcre | * |
| magento/framework | ^101.0\|^102.0\|^103.0 |
| magento/module-backend | ^100.0\|^101.0\|^102.0 |
| magento/module-checkout | ^100.0 |
| magento/module-cms | ^100.0\|^101.0\|^102.0\|^103.0\|^104.0 |
| magento/module-quote | ^100.1\|^101.0\|^102.0 |
| magento/module-store | ^100.1\|^101.0 |
| psr/log | ^1 \|\| ^2 \|\| ^3 |

### Require (dev)

| Package | Constraint |
|---|---|
| composer/composer | *@dev |
| phpunit/phpunit | * |

### Suggest

| Package | Constraint |
|---|---|
| yireo/magento2-salesblock2-by-email | * |
| yireo/magento2-salesblock2-by-geo | * |
| yireo/magento2-salesblock2-by-ip | * |

## Quality

Latest release (2.2.7) 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 | – | – | 1 | 1 |


### 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 | Warning | 106 | 106 warnings (ruleset: Magento2) — 89 auto-fixable with phpcbf |
| PHPMD | Warning | 17 | 17 rule violations (UnusedFormalParameter:6, UndefinedVariable:4, IfStatementAssignment:4, MissingImport:2, EmptyCatchBlock:1) |
| Cpd | Warning | 1 | 1 duplicated chunk spanning 27 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 | 54 | 54 | – | – |
| 2.4.8 | – | 54 | 54 | – |
| 2.4.9 | – | – | 54 | 54 |


### 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 | 2 | 2 | – | – |
| 2.4.8 | – | 2 | not tested | – |
| 2.4.9 | – | – | Error | not tested |


### 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=["yireo/magento2-salesblock2"],
  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

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

