PriceRule object
Price rules are a set of conditions, including entitlements and prerequisites, that must be met in order for a discount code to apply.
Required access
read_price_rules
access scope.
On this page
- Connections
- Fields
- Types that return PriceRule
- Mutations for PriceRule
- Implements
- Deprecated fields
- Samples
Connections
- discountCodes (
[PriceRuleDiscountCodeConnection!](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerulediscountcode)
)
List of the price rule’s discount codes.
Argument | Description |
---|---|
after ( [String](https://shopify.dev/docs/admin-api/graphql/reference/scalar#string-2021-01) ) |
Returns the elements that come after the specified cursor. |
before ( [String](https://shopify.dev/docs/admin-api/graphql/reference/scalar#string-2021-01) ) |
Returns the elements that come before the specified cursor. |
first ( [Int](https://shopify.dev/docs/admin-api/graphql/reference/scalar#int-2021-01) ) |
Returns up to the first n elements from the list. |
last ( [Int](https://shopify.dev/docs/admin-api/graphql/reference/scalar#int-2021-01) ) |
Returns up to the last n elements from the list. |
query ( [String](https://shopify.dev/docs/admin-api/graphql/reference/scalar#string-2021-01) ) |
Supported filter parameters: + times_used See the detailed search syntax for more information about using filters. |
reverse ( [Boolean](https://shopify.dev/docs/admin-api/graphql/reference/scalar#boolean-2021-01) ) |
Reverse the order of the underlying list. Default value: false |
savedSearchId ( [ID](https://shopify.dev/docs/admin-api/graphql/reference/scalar#id-2021-01) ) |
ID of an existing saved search. The search’s query string is used as the query argument. |
sortKey ( [DiscountCodeSortKeys](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/discountcodesortkeys) ) |
Sort the underlying list by the given key. Default value: ID |
- events (
[EventConnection!](https://shopify.dev/docs/admin-api/graphql/reference/events/eventconnection)
)
The paginated list of events associated with the price rule.
Argument | Description |
---|---|
after ( [String](https://shopify.dev/docs/admin-api/graphql/reference/scalar#string-2021-01) ) |
Returns the elements that come after the specified cursor. |
before ( [String](https://shopify.dev/docs/admin-api/graphql/reference/scalar#string-2021-01) ) |
Returns the elements that come before the specified cursor. |
first ( [Int](https://shopify.dev/docs/admin-api/graphql/reference/scalar#int-2021-01) ) |
Returns up to the first n elements from the list. |
last ( [Int](https://shopify.dev/docs/admin-api/graphql/reference/scalar#int-2021-01) ) |
Returns up to the last n elements from the list. |
query ( [String](https://shopify.dev/docs/admin-api/graphql/reference/scalar#string-2021-01) ) |
Supported filter parameters: + comments + created_at + subject_type + verb See the detailed search syntax for more information about using filters. |
reverse ( [Boolean](https://shopify.dev/docs/admin-api/graphql/reference/scalar#boolean-2021-01) ) |
Reverse the order of the underlying list. Default value: false |
sortKey ( [EventSortKeys](https://shopify.dev/docs/admin-api/graphql/reference/events/eventsortkeys) ) |
Sort the underlying list by the given key. Default value: ID |
Fields
- allocationLimit (
[Int](https://shopify.dev/docs/admin-api/graphql/reference/scalar#int-2021-01)
)
The maximum number of times that the price rule can be allocated onto an order. - allocationMethod (
[PriceRuleAllocationMethod!](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/priceruleallocationmethod)
)
The method by which the price rule’s value is allocated to its entitled items. - app (
[App](https://shopify.dev/docs/admin-api/graphql/reference/apps/app)
)
The application that created the price rule. - createdAt (
[DateTime!](https://shopify.dev/docs/admin-api/graphql/reference/scalar#datetime-2021-01)
)
The date and time when the price rule was created. - customerSelection (
[PriceRuleCustomerSelection!](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerulecustomerselection)
)
The customers that can use this price rule. - discountCodesCount (
[Int!](https://shopify.dev/docs/admin-api/graphql/reference/scalar#int-2021-01)
)
How many discount codes associated with the price rule. - endsAt (
[DateTime](https://shopify.dev/docs/admin-api/graphql/reference/scalar#datetime-2021-01)
)
The date and time when the price rule ends. For open-ended price rules, usenull
. - features (
[[PriceRuleFeature!]!](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerulefeature)
)
A list of the price rule’s features. - hasTimelineComment (
[Boolean!](https://shopify.dev/docs/admin-api/graphql/reference/scalar#boolean-2021-01)
)
Indicates whether there are any timeline comments on the price rule. - id (
[ID!](https://shopify.dev/docs/admin-api/graphql/reference/scalar#id-2021-01)
)
Globally unique identifier. - itemEntitlements (
[PriceRuleItemEntitlements!](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/priceruleitementitlements)
)
The items to which the price rule applies. - itemPrerequisites (
[PriceRuleLineItemPrerequisites!](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerulelineitemprerequisites)
)
The items required for the price rule to be applicable. - legacyResourceId (
[UnsignedInt64!](https://shopify.dev/docs/admin-api/graphql/reference/scalar#unsignedint64-2021-01)
)
The ID of the corresponding resource in the REST Admin API. - oncePerCustomer (
[Boolean!](https://shopify.dev/docs/admin-api/graphql/reference/scalar#boolean-2021-01)
)
Whether the price rule can be applied only once per customer. - prerequisiteQuantityRange (
[PriceRuleQuantityRange](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerulequantityrange)
)
The number of the entitled items must fall within this range for the price rule to be applicable. - prerequisiteShippingPriceRange (
[PriceRuleMoneyRange](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerulemoneyrange)
)
The shipping cost must fall within this range for the price rule to be applicable. - prerequisiteSubtotalRange (
[PriceRuleMoneyRange](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerulemoneyrange)
)
The sum of the entitled items subtotal prices must fall within this range for the price rule to be applicable. - prerequisiteToEntitlementQuantityRatio (
[PriceRulePrerequisiteToEntitlementQuantityRatio](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/priceruleprerequisitetoentitlementquantityratio)
)
Quantity of prerequisite items required for the price rule to be applicable, compared to quantity of entitled items. - shareableUrls (
[[PriceRuleShareableUrl!]!](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/priceruleshareableurl)
)
URLs that can be used to share the discount. - shippingEntitlements (
[PriceRuleShippingLineEntitlements!](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/priceruleshippinglineentitlements)
)
The shipping lines to which the price rule applies. - startsAt (
[DateTime!](https://shopify.dev/docs/admin-api/graphql/reference/scalar#datetime-2021-01)
)
The date and time when the price rule starts. - status (
[PriceRuleStatus!](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerulestatus)
)
The status of the price rule. - summary (
[String](https://shopify.dev/docs/admin-api/graphql/reference/scalar#string-2021-01)
)
A detailed summary of the price rule. - target (
[PriceRuleTarget!](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/priceruletarget)
)
The type of lines (line_item or shipping_line) to which the price rule applies. - title (
[String!](https://shopify.dev/docs/admin-api/graphql/reference/scalar#string-2021-01)
)
The title of the price rule. - totalSales (
[MoneyV2](https://shopify.dev/docs/admin-api/graphql/reference/common-objects/moneyv2)
)
The total sales from orders where the price rule was used. - usageCount (
[Int!](https://shopify.dev/docs/admin-api/graphql/reference/scalar#int-2021-01)
)
The number of times that the price rule has been used. This value is updated asynchronously and can be different than the actual usage count. - usageLimit (
[Int](https://shopify.dev/docs/admin-api/graphql/reference/scalar#int-2021-01)
)
The maximum number of times that the price rule can be used in total. - validityPeriod (
[PriceRuleValidityPeriod!](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerulevalidityperiod)
)
A time period during which a price rule is applicable. - valueV2 (
[PricingValue!](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricingvalue)
)
The value of the price rule.
Types that return PriceRule
[QueryRoot.priceRule](https://shopify.dev/docs/admin-api/graphql/reference/common-objects/queryroot#pricerule-2021-01)
[QueryRoot.priceRules](https://shopify.dev/docs/admin-api/graphql/reference/common-objects/queryroot#pricerules-2021-01)
Mutations for PriceRule
- priceRuleActivate
Activate a price rule. - priceRuleCreate
Create a price rule using the input. - priceRuleDeactivate
Deactivate a price rule. - priceRuleDelete
Delete a price rule. - priceRuleUpdate
Update a price rule using its id and an input.
Implements
[CommentEventSubject](https://shopify.dev/docs/admin-api/graphql/reference/events/commenteventsubject)
[HasEvents](https://shopify.dev/docs/admin-api/graphql/reference/events/hasevents)
[LegacyInteroperability](https://shopify.dev/docs/admin-api/graphql/reference/common-objects/legacyinteroperability)
[Node](https://shopify.dev/docs/admin-api/graphql/reference/common-objects/node)
Deprecated fields
An auto-generated type for paginating through multiple PriceRules.
On this page
Fields
- edges (
[[PriceRuleEdge!]!](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerule)
)
A list of edges. - pageInfo (
[PageInfo!](https://shopify.dev/docs/admin-api/graphql/reference/pageinfo)
)
Information to aid in pagination.
An auto-generated type which holds one PriceRule and a cursor during pagination.
On this page
Fields
- cursor (
[String!](https://shopify.dev/docs/admin-api/graphql/reference/scalar#string-2021-01)
)
A cursor for use in pagination. - node (
[PriceRule!](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerule)
)
The item at the end of PriceRuleEdge.
Types that return PriceRuleEdge
[PriceRuleConnection.edges](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerule#edges-2021-01)