johnhenry / craft-pricing-rules-relationship
A field that ties Craft Commerce catalog pricing rules to any element, so offer pages list the products those rules cover.
Package info
github.com/john-henry/craft-pricing-rules-relationship
Type:craft-plugin
pkg:composer/johnhenry/craft-pricing-rules-relationship
Requires
- php: ^8.2 || ^8.3 || ^8.4
- craftcms/cms: ^5.0
- craftcms/commerce: ^5.0
Requires (Dev)
- craftcms/ecs: dev-main
- craftcms/phpstan: dev-main
- phpstan/phpstan: ^2.2
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-27 15:32:26 UTC
README
Pricing Rules Relationship for Craft Commerce
Pricing Rules Relationship adds a field that links Craft Commerce catalog pricing rules to an entry, or to any other element. Tick the rules that apply and your template gets the products they cover. When a rule starts or ends, the page changes with it, so nobody has to go back and fix it by hand.
Features
- Any element: put the field on entries, products, categories or your own element types.
- A checkbox list for editors: they tick the rules that apply. Each rule can show its end date, and one that hasn't started yet shows its start date, so a sale can be set up ahead of time.
- Rules come and go on their own: expired, switched-off and not-yet-started rules give no products, so nobody has to untick anything. A rule that's switched back on or extended comes back by itself.
- Customer groups: a rule limited to a customer group only returns its products to customers in that group.
- Stock: pass
trueas the second argument togetProductIds()and out-of-stock products are left out. - New rule button: editors who can create pricing rules get a button that opens a new rule in Commerce, in a new tab.
- Twig, element queries and GraphQL:
craft.pricingRulesRelationship.getProductIds()gives you the product IDs for a product query, the field works as an element query param, andpricingRuleProductsdoes the same job for a headless front end.
Documentation
The full documentation is at johnhenry.ie/plugins/pricing-rules-relationship/docs.
Requirements
- Craft CMS 5.0 or later
- Craft Commerce 5.0 or later
- PHP 8.2 or later
Accessibility
How accessible the plugin is, what's been checked and how to report a problem are all in the accessibility statement.
Support
If you need a hand, open an issue on the GitHub Issues page.
License
This plugin is free to use under the MIT License.