Skip to main content

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.


Anchor to Build with the GraphQL Admin APIBuild with the GraphQL Admin API

The GraphQL Admin API enables you to create and manage Shopify discounts.

You can create discounts that are either applied automatically, or applied with discount codes.

The following table describes the different discount methods you can use as part of your app using the GraphQL Admin API:

Discount methodDescriptionExample use cases
Automatic discount

A discount that's automatically applied at checkout and on a cart if prerequisites are met.

- A Buy X Get Y or Spend X Get Y automatic discount
- A percentage or fixed-amount automatic discount
Code discount

A discount that customers can redeem using a specific code. Merchants can create and share discount codes individually with customers.

- A Buy X Get Y or Spend X Get Y code discount
- A percentage or fixed-amount code discount
- A free shipping code discount

Visit the Shopify Help Center to learn about the limitations and considerations that apply to each discount type:

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 scopeRequired or optional?Description
write_discountsRequiredAllows apps to create and update Shopify discounts
read_customersOptionalAllows apps to query a store's customers
read_productsOptionalAllows apps to query a store's products
read_shippingOptionalAllows apps to query the countries that a store ships to

Anchor to Build with Shopify FunctionsBuild 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 a single discount that can reduce the price of a product and shipping rate at once, or volume discounts with different discount rates when a line item quantity meets defined thresholds.

When you create and deploy an app with a Function, you can define a new discount type. After merchants install the app, they can create discounts using these custom discount types. Shopify executes the Function to calculate discounts in real-time when buyers add products to their cart.

How a developer can create, test, and deploy a Function

Anchor to How discounts are appliedHow discounts are applied

Shopify's discount system allows for targeted price reductions across different parts of the shopping experience. Discounts can be applied to the following:

  • Cart lines: Reductions applied to specific products in the cart

  • Order subtotals: Discounts applied to the entire purchase amount

  • Shipping rates: Reductions in shipping costs

    When you create a Discount, you can specify where the discount should be applied by defining discount classes on a discount instance. These classes determine which part of the cart the discount Function targets, enabling Shopify to correctly calculate and apply the appropriate price reduction during checkout.

Discount classes are used to define the effect of a discount on a cart. The discount's discountClasses field determines which Function targets will be executed during checkout.

App discounts built with the Discount Function API can return operations that use Order and Product discount classes in their CartLinesDiscountsGenerateRunResult and the Shipping class in CartDeliveryOptionsDiscountsGenerateRunResult.

Discount ClassAPI TargetDescription
OrderCartLinesDiscountsGenerateRunResultApplies discounts to the entire cart through cart operations
ProductCartLinesDiscountsGenerateRunResultApplies discounts to specific products through cart operations
ShippingCartDeliveryOptionsDiscountsGenerateRunResultApplies discounts to shipping rates through delivery operations

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.

Anchor to Automatic discount mutationsAutomatic discount mutations

The following table outlines some common mutations for creating, updating, and deleting automatic discounts:

Anchor to Code discount mutationsCode discount mutations

The following table outlines some common mutations for creating, updating, and deleting code discounts:

The following table outlines some common queries for interacting with automatic and code discounts.

Discount typeQueries
Automatic discountsautomaticDiscountNode
automaticDiscountNodes
Code discountscodeDiscountNode
codeDiscountNodes


Anchor to Developer tools and resourcesDeveloper tools and resources

Explore the following developer tools and resources to learn more about building with Shopify Functions:


Was this page helpful?