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 APIAnchor link to section titled "Build with the GraphQL Admin API"
The GraphQL Admin API enables you to create and manage Shopify discounts.
Discount typesAnchor link to section titled "Discount types"
You can create different types of discounts to offer to customers using the GraphQL Admin API. For example, an app user might want to use discounts as a way to promote sales, as special offers, or as customer loyalty rewards.
The following table describes the different types of discounts that you can create as part of your app:
|Discount type||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 scopesAnchor 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|
||Required||Allows apps to create and update Shopify discounts|
||Optional||Allows apps to query a store's customers|
||Optional||Allows apps to query a store's products|
||Optional||Allows apps to query the countries that a store ships to|
Build with Shopify FunctionsAnchor 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 classesAnchor 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 (Developer preview)||A discount that's applied to one or more shipping rates at checkout||
Developer tools and resourcesAnchor link to section titled "Developer tools and resources"
Explore the following developer tools and resources to learn more about building with Shopify Functions:
Input queries and metafields
Make your code reusable by replacing hard-coded variables in your function with metafield values.