# PriceRule - admin-graphql - OBJECT Version: 2024-04 ## Description 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](https://shopify.dev/docs/apps/selling-strategies/discounts/getting-started) instead. These will replace the GraphQL `PriceRule` object and REST Admin `PriceRule` and `DiscountCode` resources. ### Access Scopes `read_price_rules` access scope. ## Fields * [allocationLimit](/docs/api/admin-graphql/2024-04/scalars/Int): Int - The maximum number of times that the price rule can be allocated onto an order. * [allocationMethod](/docs/api/admin-graphql/2024-04/enums/PriceRuleAllocationMethod): PriceRuleAllocationMethod! - The method by which the price rule's value is allocated to its entitled items. * [app](/docs/api/admin-graphql/2024-04/objects/App): App - The application that created the price rule. * [combinesWith](/docs/api/admin-graphql/2024-04/objects/DiscountCombinesWith): DiscountCombinesWith! - The [discount classes](https://help.shopify.com/manual/discounts/combining-discounts/discount-combinations) that you can use in combination with [Shopify discount types](https://help.shopify.com/manual/discounts/discount-types). * [createdAt](/docs/api/admin-graphql/2024-04/scalars/DateTime): DateTime! - The date and time when the price rule was created. * [customerSelection](/docs/api/admin-graphql/2024-04/objects/PriceRuleCustomerSelection): PriceRuleCustomerSelection! - The customers that can use this price rule. * [discountClass](/docs/api/admin-graphql/2024-04/enums/DiscountClass): DiscountClass! - The [discount class](https://help.shopify.com/manual/discounts/combining-discounts/discount-combinations) that's used to control how discounts can be combined. * [discountCodesCount](/docs/api/admin-graphql/2024-04/objects/Count): Count - How many discount codes associated with the price rule. * [endsAt](/docs/api/admin-graphql/2024-04/scalars/DateTime): DateTime - The date and time when the price rule ends. For open-ended price rules, use `null`. * [entitlementToPrerequisiteQuantityRatio](/docs/api/admin-graphql/2024-04/objects/PriceRuleEntitlementToPrerequisiteQuantityRatio): PriceRuleEntitlementToPrerequisiteQuantityRatio - Quantity of prerequisite items required for the price rule to be applicable, compared to quantity of entitled items. * [features](/docs/api/admin-graphql/2024-04/enums/PriceRuleFeature): PriceRuleFeature! - A list of the price rule's features. * [hasTimelineComment](/docs/api/admin-graphql/2024-04/scalars/Boolean): Boolean! - Indicates whether there are any timeline comments on the price rule. * [id](/docs/api/admin-graphql/2024-04/scalars/ID): ID! - A globally-unique ID. * [itemEntitlements](/docs/api/admin-graphql/2024-04/objects/PriceRuleItemEntitlements): PriceRuleItemEntitlements! - The items to which the price rule applies. * [itemPrerequisites](/docs/api/admin-graphql/2024-04/objects/PriceRuleLineItemPrerequisites): PriceRuleLineItemPrerequisites! - The items required for the price rule to be applicable. * [legacyResourceId](/docs/api/admin-graphql/2024-04/scalars/UnsignedInt64): UnsignedInt64! - The ID of the corresponding resource in the REST Admin API. * [oncePerCustomer](/docs/api/admin-graphql/2024-04/scalars/Boolean): Boolean! - Whether the price rule can be applied only once per customer. * [prerequisiteQuantityRange](/docs/api/admin-graphql/2024-04/objects/PriceRuleQuantityRange): PriceRuleQuantityRange - The number of the entitled items must fall within this range for the price rule to be applicable. * [prerequisiteShippingPriceRange](/docs/api/admin-graphql/2024-04/objects/PriceRuleMoneyRange): PriceRuleMoneyRange - The shipping cost must fall within this range for the price rule to be applicable. * [prerequisiteSubtotalRange](/docs/api/admin-graphql/2024-04/objects/PriceRuleMoneyRange): PriceRuleMoneyRange - The sum of the entitled items subtotal prices must fall within this range for the price rule to be applicable. * [prerequisiteToEntitlementQuantityRatio](/docs/api/admin-graphql/2024-04/objects/PriceRulePrerequisiteToEntitlementQuantityRatio): PriceRulePrerequisiteToEntitlementQuantityRatio - Quantity of prerequisite items required for the price rule to be applicable, compared to quantity of entitled items. * [shareableUrls](/docs/api/admin-graphql/2024-04/objects/PriceRuleShareableUrl): PriceRuleShareableUrl! - URLs that can be used to share the discount. * [shippingEntitlements](/docs/api/admin-graphql/2024-04/objects/PriceRuleShippingLineEntitlements): PriceRuleShippingLineEntitlements! - The shipping lines to which the price rule applies. * [startsAt](/docs/api/admin-graphql/2024-04/scalars/DateTime): DateTime! - The date and time when the price rule starts. * [status](/docs/api/admin-graphql/2024-04/enums/PriceRuleStatus): PriceRuleStatus! - The status of the price rule. * [summary](/docs/api/admin-graphql/2024-04/scalars/String): String - A detailed summary of the price rule. * [target](/docs/api/admin-graphql/2024-04/enums/PriceRuleTarget): PriceRuleTarget! - The type of lines (line_item or shipping_line) to which the price rule applies. * [title](/docs/api/admin-graphql/2024-04/scalars/String): String! - The title of the price rule. * [totalSales](/docs/api/admin-graphql/2024-04/objects/MoneyV2): MoneyV2 - The total sales from orders where the price rule was used. * [traits](/docs/api/admin-graphql/2024-04/enums/PriceRuleTrait): PriceRuleTrait! - A list of the price rule's features. * [usageCount](/docs/api/admin-graphql/2024-04/scalars/Int): Int! - 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](/docs/api/admin-graphql/2024-04/scalars/Int): Int - The maximum number of times that the price rule can be used in total. * [validityPeriod](/docs/api/admin-graphql/2024-04/objects/PriceRuleValidityPeriod): PriceRuleValidityPeriod! - A time period during which a price rule is applicable. * [value](/docs/api/admin-graphql/2024-04/unions/PriceRuleValue): PriceRuleValue! - The value of the price rule. * [valueV2](/docs/api/admin-graphql/2024-04/unions/PricingValue): PricingValue! - The value of the price rule. ## Connections * [discountCodes](/docs/api/admin-graphql/2024-04/connections/PriceRuleDiscountCodeConnection): PriceRuleDiscountCodeConnection! * [events](/docs/api/admin-graphql/2024-04/connections/EventConnection): EventConnection! ## Related queries * [priceRule](/docs/api/admin-graphql/2024-04/queries/priceRule) Returns a code price rule resource by ID. * [priceRules](/docs/api/admin-graphql/2024-04/queries/priceRules) Returns a list of price rule resources that have at least one associated discount code. ## Related mutations * [priceRuleActivate](/docs/api/admin-graphql/2024-04/mutations/priceRuleActivate) Activate a price rule. * [priceRuleCreate](/docs/api/admin-graphql/2024-04/mutations/priceRuleCreate) Create a price rule using the input. * [priceRuleDeactivate](/docs/api/admin-graphql/2024-04/mutations/priceRuleDeactivate) Deactivate a price rule. * [priceRuleDiscountCodeCreate](/docs/api/admin-graphql/2024-04/mutations/priceRuleDiscountCodeCreate) Create a discount code for a price rule. * [priceRuleDiscountCodeUpdate](/docs/api/admin-graphql/2024-04/mutations/priceRuleDiscountCodeUpdate) Update a discount code for a price rule. * [priceRuleUpdate](/docs/api/admin-graphql/2024-04/mutations/priceRuleUpdate) Updates a price rule using its ID and an input. ## Related Unions ## Examples ### Retrieve a price rule by its ID Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query GetPriceRule($id: ID!) { priceRule(id: $id) { id title status } }\",\n \"variables\": {\n \"id\": \"gid://shopify/PriceRule/1057371215\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query GetPriceRule($id: ID!) {\n priceRule(id: $id) {\n id\n title\n status\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/PriceRule/1057371215\"\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query GetPriceRule($id: ID!) {\n priceRule(id: $id) {\n id\n title\n status\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/PriceRule/1057371215\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query GetPriceRule($id: ID!) {\n priceRule(id: $id) {\n id\n title\n status\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/PriceRule/1057371215\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query GetPriceRule($id: ID!) {\n priceRule(id: $id) {\n id\n title\n status\n }\n}" #### Graphql Input { "id": "gid://shopify/PriceRule/1057371215" } #### Graphql Response { "data": { "priceRule": { "id": "gid://shopify/PriceRule/1057371215", "title": "PROTABO", "status": "ACTIVE" } } }