priceRule
Deprecated. Use `codeDiscountNode` instead.
Returns a code price rule resource by ID.
Anchor to Possible returnsPossible returns
- Anchor to PriceRulePrice•
Rule Price rules are a set of conditions, including entitlements and prerequisites, that must be met in order for a discount code to apply.
We recommend using the types and queries detailed at Getting started with discounts instead. These will replace the GraphQL
object and REST Admin
and
resources.
- allocation
Limit •Int The maximum number of times that the price rule can be allocated onto an order.
- allocation
Method •Pricenon-nullRule Allocation Method! The method by which the price rule's value is allocated to its entitled items.
- app•App
The application that created the price rule.
- combines
With •Discountnon-nullCombines With! The discount classes that you can use in combination with Shopify discount types.
- created
At •Datenon-nullTime! The date and time when the price rule was created.
- customer
Selection •Pricenon-nullRule Customer Selection! The customers that can use this price rule.
- discount
Class •Discountnon-nullClass! The discount class that's used to control how discounts can be combined.
- discount
Codes • Pricenon-nullRule Discount Code Connection! List of the price rule's discount codes.
- discount
Codes •Count Count How many discount codes associated with the price rule.
- ends
At •DateTime The date and time when the price rule ends. For open-ended price rules, use
null
.- events
• Eventnon-nullConnection! The paginated list of events associated with the price rule.
- features•[Pricenon-null
Rule Feature!]! A list of the price rule's features.
- has
Timeline •Comment Boolean!non-null Indicates whether there are any timeline comments on the price rule.
- id•ID!non-null
A globally-unique ID.
- item
Entitlements •Pricenon-nullRule Item Entitlements! The items to which the price rule applies.
- item
Prerequisites •Pricenon-nullRule Line Item Prerequisites! The items required for the price rule to be applicable.
- legacy
Resource •Id Unsignednon-nullInt64! The ID of the corresponding resource in the REST Admin API.
- once
Per •Customer Boolean!non-null Whether the price rule can be applied only once per customer.
- prerequisite
Quantity •Range PriceRule Quantity Range The number of the entitled items must fall within this range for the price rule to be applicable.
- prerequisite
Shipping •Price Range PriceRule Money Range The shipping cost must fall within this range for the price rule to be applicable.
- prerequisite
Subtotal •Range PriceRule Money Range The sum of the entitled items subtotal prices must fall within this range for the price rule to be applicable.
- prerequisite
To •Entitlement Quantity Ratio PriceRule Prerequisite To Entitlement Quantity Ratio Quantity of prerequisite items required for the price rule to be applicable, compared to quantity of entitled items.
- shareable
Urls •[Pricenon-nullRule Shareable Url!]! URLs that can be used to share the discount.
- shipping
Entitlements •Pricenon-nullRule Shipping Line Entitlements! The shipping lines to which the price rule applies.
- starts
At •Datenon-nullTime! The date and time when the price rule starts.
- status•Pricenon-null
Rule Status! The status of the price rule.
- summary•String
A detailed summary of the price rule.
- target•Pricenon-null
Rule Target! The type of lines (line_item or shipping_line) to which the price rule applies.
- title•String!non-null
The title of the price rule.
- total
Sales •MoneyV2 The total sales from orders where the price rule was used.
- usage
Count •Int!non-null 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.
- usage
Limit •Int The maximum number of times that the price rule can be used in total.
- validity
Period •Pricenon-nullRule Validity Period! A time period during which a price rule is applicable.
- value
V2 •Pricingnon-nullValue! The value of the price rule.
- entitlement
To •Prerequisite Quantity Ratio PriceRule Entitlement To Prerequisite Quantity Ratio Quantity of prerequisite items required for the price rule to be applicable, compared to quantity of entitled items.
- traits•[Pricenon-null
Rule Trait!]! A list of the price rule's features.
- value•Pricenon-null
Rule Value! The value of the price rule.
- allocation
Retrieve a price rule by its ID
query GetPriceRule($id: ID!) {
priceRule(id: $id) {
id
title
status
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-07/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query GetPriceRule($id: ID!) { priceRule(id: $id) { id title status } }",
"variables": {
"id": "gid://shopify/PriceRule/1057371215"
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query GetPriceRule($id: ID!) {
priceRule(id: $id) {
id
title
status
}
}`,
{
variables: {
"id": "gid://shopify/PriceRule/1057371215"
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `query GetPriceRule($id: ID!) {
priceRule(id: $id) {
id
title
status
}
}`,
"variables": {
"id": "gid://shopify/PriceRule/1057371215"
},
},
});
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
query GetPriceRule($id: ID!) {
priceRule(id: $id) {
id
title
status
}
}
QUERY
variables = {
"id": "gid://shopify/PriceRule/1057371215"
}
response = client.query(query: query, variables: variables)