PriceRule

Version 2019-10

You can use the PriceRule resource to create discounts using conditions. You can then associate the conditions with a discount code by using the DiscountCode resource. Merchants can distribute the discount codes to their customers.

Using the PriceRule resource, you can create discounts that specify a discount as a percentage, a fixed amount, or free shipping. You use entitlements and prerequisites to dynamically build these discounts.

To learn about how to associate a price rule with a discount code, see the DiscountCode resource.

Create a price rule

You can create price rules with entitlements and prerequisites. Entitlements describe the designated resources that a discount applies to, such as specific products, variants, or collections. Prerequisites describe the requirements that must be met in order for the discount to apply to the entitled resources. For example, you might want a discount to apply only to a certain shipping price range, or a certain subtotal range.

You can use entitlements, prereqisites, and other conditions to create discounts, such as the following examples:

  • $10 off the buyer's order if the total exceeds $40
  • 15% off certain collections
  • free shipping on orders over $100.00 for Canadian buyers, redeemable up to 20 times

For examples of how to create price rules, see the POST method.

What you can do with PriceRule

The Shopify API lets you do the following with the PriceRule resource. More detailed versions of these general actions may be available:

PriceRule properties

allocation_method
"allocation_method": "each"

The allocation method of the price rule. Valid values:

  • each: The discount is applied to each of the entitled items. For example, for a price rule that takes $15 off, each entitled line item in a checkout will be discounted by $15.
  • across: The calculated discount amount will be applied across the entitled items. For example, for a price rule that takes $15 off, the discount will be applied across all the entitled items.

When the value of target_type is shipping_line, then this value must be each.

created_at
read-only
"created_at": "2017-03-13T16:09:54-04:00"

The date and time (ISO 8601 format) when the price rule was created.

updated_at
read-only
"updated_at": "2017-03-14T16:09:54-04:00"

The date and time (ISO 8601 format) when the price rule was updated.