Create automatic discounts
You can create discounts that are automatically applied to a cart if prerequisites are met. This guide shows you how to create different types of automatic discounts using the GraphQL Admin API.
Requirements
Anchor link to section titled "Requirements"- Your app can make authenticated requests to the GraphQL Admin API.
- Your app has the
write_discounts
access scope.
Step 1: Create a Buy X Get Y or Spend X Get Y automatic discount
Anchor link to section titled "Step 1: Create a Buy X Get Y or Spend X Get Y automatic discount"A Buy X Get Y or Spend X Get Y are automatic discounts that offers customer discounts on select products if they add a specific product to their order. You can use the discountAutomaticBxgyCreate
mutation to create a Buy X Get Y or Spend X Get Y automatic discount.
The following example shows how to create an automatic Buy One Get One discount that will be applied to a single product any time it’s included in a cart. In this case, it applies a 100% discount on the second item in a cart, as long as it’s the same product as the first item.
The discount displays in the Discounts section of the Shopify admin:
Step 2: Create a percentage or fixed-amount automatic discount
Anchor link to section titled "Step 2: Create a percentage or fixed-amount automatic discount"You can use the discountAutomaticBasicCreate
mutation to offer customers a basic discount using a fixed percentage, or a fixed amount, on specific products from the order.
The following example shows how to create an automatic discount of 10% that will be applied to a single product any time it’s included in a cart. The percentage
input requires a value between 0 and 1.
The discount displays in the Discounts section of the Shopify admin:
- Create a discount that includes a unique code.
- Manage and make changes to existing discounts.