Catalog Pricing Rules

Pricing rules are sets of conditions and actions that determine prices of purchasables.

The catalog pricing system replaces sales from earlier versions of Commerce. If you upgraded your store from 4.x to 5.x and had already configured one or more sales, you will retain access to them—but we strongly recommend migrating your sales into pricing rules.

Catalog pricing is computed and stored in the database when its underlying data changes. Prices can also be manually refreshed at any time (or on a schedule) with the commerce/pricing-catalog/generate console command.

The resulting pricing information is joined in with normal variant queries and available transparently on the returned elements—even when rules produce customer-specific pricing!

To create a pricing rule, visit

  1. Commerce
  2. Store Management
  3. Pricing Rules
, and click New catalog pricing rule.

# Conditions

A pricing rule applies to any purchasable that satisfies its Conditions, but may can be scoped to a specific set of Customers (Craft users).

Start Date
Apply this rule after the chosen date.
End Date
Apply this rule before the chosen date.
Match Product 5.1.0+
Apply the rule only to purchasables belonging to products that match the provided conditions.
Match Variant 5.1.0+
Apply the rule only to variants matching the provided condition.
Match Purchasable
Set conditions that apply to any type of purchasable, including those provided by plugins.
Match Customers
Make the rule available only to customers who match the provided conditions. Rules that include customer conditions are implicitly limited to registered users.

If no conditions are configured, the rule will match all purchasables, and all customers (whether or not they are logged in).

# Actions

When a rule matches a purchasable, its Action is applied. An action takes the matched purchasable’s price or promotional price, performs the defined arithmetic, and places the result in the pricing catalog as the new price or promotional price.

You can think of a pricing rule as having an independent input and output. The input can come from the purchasable’s price or promotional price, and the output can be directed to the purchasable’s price or promotional price.

The possible actions are:

Action Effect Source Price
Reduce price… …by a percentage of… …the original price.
…the original promotional price.
…by a fixed amount from… …the original price.
…the original promotional price.
Set price… …to a percentage of… …the original price.
…the original promotional price.
…to a flat amount.

Use the Is Promotional Price? toggle to choose which price the rule will affect. When this is off, the computed value becomes the price; when it’s on, the computed value becomes the promotional price.

All pricing rules operate on the purchasable’s original price or original promotional price. Pricing rules do not stack.

# Conflicts

More than one pricing rule can match a purchasable. In the event of such an overlap, Commerce selects the lowest calculated price that would apply. Prices and promotional prices are always kept separate, as are the prices for each store.

# Debugging

To visualize what pricing a customer will see, you can pass their user ID to the .forCustomer() variant query param:

{% set user = craft.users()
  .username('oli')
  .one() %}

{% set myVariant = craft.variants()
  .id(1234)
  .forCustomer(user.id)
  .one() %}

{{ user.fullName }} would pay <del>{{ myVariant.price|commerceCurrency }}</del> {{ myVariant.promotionalPrice|commerceCurrency }}

Similarly, to check the price for a guest, you can pass false, explicitly:

{% set myVariant = craft.variants()
  .forCustomer(false)
  .one() %}

A guest would pay <del>{{ myVariant.price|commerceCurrency }}</del> {{ myVariant.promotionalPrice|commerceCurrency }}

# Dynamic Pricing

The pricing catalog and discounts both operate on preestablished criteria and actions. In situations where a price needs to be dynamically calculated (say, from customer input in the form of custom fields or line item options), Commerce gives you complete control over pricing and cart contents via its events system.

Read about dynamically changing line item prices (opens new window) in the Knowledge Base.