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.getSaleIds() 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, shows its start date, and stays out until it goes live. Disabled rules stay out too. If a rule comes back or gets 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.
Customers only see what's meant for them
- 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 the store still uses the old Sales, you get a notice, because Commerce then ignores catalog pricing rules
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 expiry 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 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.



