windandkite / module-additional-conditions
Adds starts with, does not start with, and regex condition operators to Magento 2 price rules.
Package info
github.com/windandkite/module-additional-conditions
Type:magento2-module
pkg:composer/windandkite/module-additional-conditions
Requires
- php: >=8.1
- magento/framework: *
- magento/module-sales-rule: *
This package is auto-updated.
Last update: 2026-07-23 15:31:54 UTC
README
A Magento 2 Module that extends Magento 2 cart and catalog price rule conditions by adding custom global pattern-matching operators (starts with, starts with (case sensitive), does not start with, does not start with (case sensitive), and matches regex) for all string attributes.
Why is it needed
Standard Magento Open Source provides limited condition operators for text attributes in sales rules (such as contains, is, or is one of). This creates significant limitations when attempting to build targeted promotional or shipping rules:
- Postcode Prefixes: Matching UK postcode areas (e.g. matching
BG1 5TGstarting withBGwithout false-positive matching on postcodes likeTS1 5BG) is impossible with nativecontains. - RegEx Pattern Matching: Grouping multiple postcode prefixes, SKU patterns, or regional names natively requires creating dozens of repetitive rule conditions.
- Case Sensitivity Control: Easily distinguish exact-case identifiers (e.g.
shirt-redvsSHIRT-RED) without needing complex regular expressions.
WindAndKite_AdditionalConditions solves this globally by adding five high-performance, vendor-prefixed operators (wk_starts_with, wk_starts_with_case, wk_not_starts_with, wk_not_starts_with_case, wk_regex) to all string input conditions across Magento price rules using modern PHP 8.1+ syntax.
Installation
Install via composer
Our modules are hosted on our public packagist account and can very easily be installed via composer:
composer require windandkite/module-additional-conditions
Enable the module
You can enable the module by running one of the following commands:
bin/magento module:enable WindAndKite_AdditionalConditions
or
bin/magento setup:upgrade
Setup
No additional administrative configuration is required. Once enabled, navigate to Marketing > Cart Price Rules (or Catalog Price Rules), create or edit a rule, and select any text/string attribute (such as Shipping Postcode, SKU, or City).
The new options will automatically appear in the operator dropdown menu:
- starts with: Case-insensitive prefix evaluation (
str_starts_with). - starts with (case sensitive): Strict case-sensitive prefix evaluation (
str_starts_with). - does not start with: Inverted case-insensitive prefix evaluation (
!str_starts_with). - does not start with (case sensitive): Inverted strict case-sensitive prefix evaluation (
!str_starts_with). - matches regex: Fully featured Regular Expression matching using
preg_match.
Examples
| Rule Scenario | Attribute | Selected Operator | Value |
|---|---|---|---|
Target single area postcodes (e.g. BG1...) |
Shipping Postcode | starts with |
BG |
| Exclude specific region postcodes | Shipping Postcode | does not start with |
BT |
| Match precise case-sensitive SKU prefixes | SKU | starts with (case sensitive) |
PROMO_ |
| Exclude specific case-sensitive SKUs | SKU | does not start with (case sensitive) |
DRAFT_ |
| Target multiple UK Postcode prefixes | Shipping Postcode | matches regex |
`/^(BG |
| Match SKUs with specific naming patterns | SKU | matches regex |
`/^SHIRT-(RED |
Contributions
To contribute to this project please install the package with the --prefer-source flag to download the Git source, any changes should then be pushed to GitHub and follow the usual Code Review Process. Once reviewed and merged in please create a release and appropriate tag for the changes ensuring to follow Semver.