Pricing Rules Relationship

"Can we have a Special Offers page?"
A client asks for a Special Offers page, or a page for the autumn sale. The catalog pricing rules are already set up in Commerce, but there's no way to point a page at them. Commerce has the rules and Craft has relationships between elements, and the two don't meet. So someone ends up picking the products by hand, and the page is out of date the day the sale ends.
Pricing Rules Relationship adds a field that joins them. Put it on an entry, product, category or any other element and editors get a checkbox list of your store's pricing rules. They tick the ones that apply. In your template, craft.pricingRulesRelationship.getProductIds() gives you the IDs of every product those rules cover, ready for a product query.

Pages that keep themselves right
Expired rules drop out of your templates on their own, so nobody has to untick anything. A rule that hasn't started yet can be ticked ahead of time. It shows its start date in the field and gives no products until it goes live. Switched-off rules give none either. If a rule is switched back on or extended, the entry still has it ticked. Craft's caches for a page built this way expire when one of its rules starts or ends, so an offer doesn't outlive its dates.
Who sees what
- A rule limited to a customer group only returns its products to customers in that group
- Only live products from the current store come back, and the in-stock filter checks that store's stock
- Editors without Commerce's Manage promotions permission are only offered rules open to every customer, since a rule's name can say more than you'd want. If every rule is limited to particular customers, the field tells them so rather than saying there are none
If the store still uses legacy Sales, the field tells editors, because Commerce ignores catalog pricing rules while those are in place.
What's in it
| Feature | What it does |
|---|---|
| Pricing rules field | For entries, products, categories and custom elements |
| Editors | A checkbox list, with each rule's end date beside it if you want it |
| Twig | One call for the matching product IDs, with an optional in-stock filter |
| Element queries | The field as a query param, so you can find the entries that use a rule |
| GraphQL | The field, plus pricingRuleProducts and pricingRuleProductCount so a headless front end can build the same offer pages |
| New rule button | Opens a new pricing rule in Commerce, in a new tab |
| Empty state | Your own text for when there are no rules to offer |
It's free. It needs Craft CMS 5, Craft Commerce 5 and PHP 8.2 or later.
Accessibility
What's been checked, and anything that still needs work, is in the accessibility statement.
To install this plugin, copy the command above to your terminal.
This plugin doesn't have any reviews.



