About discounts
Discount apps integrate with the Shopify admin to provide discount types for app users. This guide introduces the ways that you can extend your app code into Shopify checkout and customize the discount experience.
- Use the GraphQL Admin API to create and manage discounts that are native to Shopify.
- Use Shopify Functions to extend your app code into Shopify checkout and create discount functionality that isn't offered out of the box with Shopify.
Build with the GraphQL Admin API
Anchor link to section titled "Build with the GraphQL Admin API"The GraphQL Admin API enables you to create and manage Shopify discounts.
Discount methods
Anchor link to section titled "Discount methods"You can create discounts that are either applied automatically, or via discount codes.
The following table describes the different discount methods you can use as part of your app using the GraphQL Admin API:
Discount method | Description | Example use cases |
---|---|---|
Automatic discount | A discount that's automatically applied at checkout and on a cart if prerequisites are met. | |
Code discount | A discount that customers can redeem using a specific code. Merchants can create and share discount codes individually with customers. |
Visit the Shopify Help Center to learn about the limitations and considerations that apply to each discount type:
Access scopes
Anchor link to section titled "Access scopes"To use discount-related GraphQL mutations when building with the GraphQL Admin API, your app needs to request the following access scopes for a Shopify store:
Access scope | Required or optional? | Description |
---|---|---|
write_discounts |
Required | Allows apps to create and update Shopify discounts |
read_customers |
Optional | Allows apps to query a store's customers |
read_products |
Optional | Allows apps to query a store's products |
read_shipping |
Optional | Allows apps to query the countries that a store ships to |
Build with Shopify Functions
Anchor link to section titled "Build with Shopify Functions"Shopify Functions enable you to create discount functionality that isn't offered out of the box with Shopify. For example, a discount function can be used to create volume discounts with different discount rates upon hitting specified volume breakpoints.
An app developer creates and deploys an app with a function that defines a new discount type. A user can then install the app on a Shopify store and create a new discount from a discount type provided by the app. Shopify executes the function to calculate the discount when a customer adds a product to their cart.
Discount classes
Anchor link to section titled "Discount classes"Discount classes are similar to native discount types. You can create one or more discount classes as part of your app using Shopify Functions.
The following table describes the different discount classes in detail:
Discount class | Description | Example use cases |
---|---|---|
Order discount | A discount that's applied to all merchandise in the cart. |
|
Product discount | A discount that's applied to a particular product or product variant in the cart |
|
Shipping discount | A discount that's applied to one or more shipping rates at checkout |
|
Related mutations and queries
Anchor link to section titled "Related mutations and queries"Explore the following resources to manage discounts in your app. Use mutations to craft, modify, and remove discounts, and use queries to retrieve detailed listings.
Automatic discount mutations
Anchor link to section titled "Automatic discount mutations"The following table outlines some common mutations for creating, updating, and deleting automatic discounts:
Discount type | Mutations |
---|---|
Buy X Get Y or Spend X Get Y |
discountAutomaticBxgyCreate discountAutomaticBxgyUpdate discountAutomaticDelete |
Percentage or fixed amount |
discountAutomaticBasicCreate discountAutomaticBasicUpdate discountAutomaticDelete |
Free shipping |
discountAutomaticFreeShippingCreate discountAutomaticFreeShippingUpdate discountAutomaticDelete |
App |
discountAutomaticAppCreate discountAutomaticAppUpdate discountAutomaticDelete |
Code discount mutations
Anchor link to section titled "Code discount mutations"The following table outlines some common mutations for creating, updating, and deleting code discounts:
Discount type | Mutations |
---|---|
Buy X Get Y or Spend X Get Y |
discountCodeBxgyCreate discountCodeBxgyUpdate discountCodeDelete |
Percentage or fixed amount |
discountCodeBasicCreate discountCodeBasicUpdate discountCodeDelete |
Free shipping |
discountCodeFreeShippingCreate discountCodeFreeShippingUpdate discountCodeDelete |
App |
discountCodeAppCreate discountCodeAppUpdate discountCodeDelete |
Bulk actions |
discountCodeBulkActivate discountCodeBulkDeactivate discountCodeBulkDelete |
The following table outlines some common queries for interacting with automatic and code discounts.
Discount type | Queries |
---|---|
Automatic discounts | automaticDiscountNode automaticDiscountNodes |
Code discounts | codeDiscountNode codeDiscountNodes |
Limitations
Anchor link to section titled "Limitations"- The maximum number of automatic app discounts for each store is five.
- Shopify Functions limitations apply.
Getting started
Anchor link to section titled "Getting started"Follow the getting started tutorials to learn how to customize and extend discounts:
Developer tools and resources
Anchor link to section titled "Developer tools and resources"Explore the following developer tools and resources to learn more about building with Shopify Functions: