priceRuleCreate mutation

Create a price rule using the input.

Required access

write_price_rules access scope.


On this page


Interactive example

This is an example mutation query. Use the embedded interactive tool below to edit the query.

Hint: use Ctrl + Space for autocompleting fields.

mutation priceRuleCreate($priceRule: PriceRuleInput!) { priceRuleCreate(priceRule: $priceRule) {
  1. <font style="color:#1F61A0;">priceRule</font> <font style="color:#555555;">{</font>
  2. <font style="color:#1F61A0;">id</font>
  3. <font style="color:#555555;">}</font>
  4. <font style="color:#1F61A0;">priceRuleDiscountCode</font> <font style="color:#555555;">{</font>
  5. <font style="color:#1F61A0;">id</font>
  6. <font style="color:#555555;">}</font>
  7. <font style="color:#1F61A0;">priceRuleUserErrors</font> <font style="color:#555555;">{</font>
  8. <font style="color:#1F61A0;">code</font>
  9. <font style="color:#1F61A0;">field</font>
  10. <font style="color:#1F61A0;">message</font>
  11. <font style="color:#555555;">}</font>
} } { “priceRule”: {} }


Arguments

Argument Description
priceRule
(
[PriceRuleInput!](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/priceruleinput)

) REQUIRED
Input fields to create a price rule.
priceRuleDiscountCode
(
[PriceRuleDiscountCodeInput](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerulediscountcodeinput)

)
Input fields to create a discount code for the price rule.


PriceRuleInput 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.
  • customerSelection ([PriceRuleCustomerSelectionInput](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerulecustomerselectioninput))
    The customers that can use this price rule.
  • entitlementToPrerequisiteQuantityRatio ([PriceRuleEntitlementToPrerequisiteQuantityRatioInput](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/priceruleentitlementtoprerequisitequantityratioinput))
    Quantity of prerequisite items required for the price rule to be applicable, compared to quantity of entitled items. This argument is deprecated: Use prerequisiteToEntitlementQuantityRatio instead.
  • itemEntitlements ([PriceRuleItemEntitlementsInput](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/priceruleitementitlementsinput))
    The items to which the price rule applies.
  • itemPrerequisites ([PriceRuleItemPrerequisitesInput](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/priceruleitemprerequisitesinput))
    The items required for the price rule to be applicable.
  • 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 ([PriceRuleQuantityRangeInput](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerulequantityrangeinput))
    The number of the entitled items must fall within this range for the price rule to be applicable.
  • prerequisiteShippingPriceRange ([PriceRuleMoneyRangeInput](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerulemoneyrangeinput))
    The shipping cost must fall within this range for the price rule to be applicable.
  • prerequisiteSubtotalRange ([PriceRuleMoneyRangeInput](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerulemoneyrangeinput))
    The sum of the entitled items subtotal prices must fall within this range for the price rule to be applicable.
  • prerequisiteToEntitlementQuantityRatio ([PriceRulePrerequisiteToEntitlementQuantityRatioInput](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/priceruleprerequisitetoentitlementquantityratioinput))
    Quantity of prerequisite items required for the price rule to be applicable, compared to quantity of entitled items.
  • shippingEntitlements ([PriceRuleShippingEntitlementsInput](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/priceruleshippingentitlementsinput))
    The shipping lines to which the price rule applies.
  • 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))
    Title of the price rule.
  • 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 ([PriceRuleValidityPeriodInput](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerulevalidityperiodinput))
    PriceRuleValidityPeriod for the price rule.
  • value ([PriceRuleValueInput](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerulevalueinput))
    The value of the price rule.


Return fields

  • priceRule ([PriceRule](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerule))
    The newly created price rule.
  • priceRuleDiscountCode ([PriceRuleDiscountCode](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerulediscountcode))
    The newly created discount code.
  • priceRuleUserErrors ([[PriceRuleUserError!]!](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/priceruleusererror))
    List of errors that occurred executing the mutation.


Deprecated return fields

  • userErrors ([[UserError!]!](https://shopify.dev/docs/admin-api/graphql/reference/usererror)) DEPRECATED
    List of errors that occurred executing the mutation.
    Deprecation warning
    Use priceRuleUserErrors instead