Skip to main content
object

Requires Apps must have read_discounts access scope.

The DiscountCodeNode object enables you to manage code discounts that are applied when customers enter a code at checkout. For example, you can offer discounts where customers have to enter a code to redeem an amount off discount on products, variants, or collections in a store. Or, you can offer discounts where customers have to enter a code to get free shipping. Merchants can create and share discount codes individually with customers.

Learn more about working with Shopify's discount model, including related queries, mutations, limitations, and considerations.

•DiscountCode!
non-null

The underlying code discount object.

•EventConnection!
non-null

The paginated list of events associated with the host subject.

•ID!
non-null

A globally-unique ID.

•Metafield

A custom field, including its namespace and key, that's associated with a Shopify resource for the purposes of adding and storing additional information.

•MetafieldConnection!
non-null

A list of custom fields that a merchant associates with a Shopify resource.

Anchor to metafieldsByIdentifiersmetafieldsByIdentifiers
•[Metafield]!
non-null

The metafields associated with the resource matching the supplied list of namespaces and keys.

Anchor to metafieldDefinitionsmetafieldDefinitions
•MetafieldDefinitionConnection!
non-nullDeprecated

Was this section helpful?

•query

Returns a code discount resource by ID.

•query

Returns a code discount identified by its discount code.

•query

Returns a list of code-based discounts.


Was this section helpful?

•mutation

Activates a previously created code discount, making it available for customers to use during checkout. This mutation transitions inactive discount codes into an active state where they can be applied to orders.

For example, after creating a "SUMMER20" discount code but leaving it inactive during setup, merchants can activate it when ready to launch their summer promotion campaign.

Use DiscountCodeActivate to:

  • Launch scheduled promotional campaigns
  • Reactivate previously paused discount codes
  • Enable discount codes after configuration changes
  • Control the timing of discount availability

The mutation returns the updated discount code node with its new active status and handles any validation errors that might prevent activation, such as conflicting discount rules or invalid date ranges.

•mutation

Creates an amount off discount that's applied on a cart and at checkout when a customer enters a code. Amount off discounts can be a percentage off or a fixed amount off.


Note

To create discounts that are automatically applied on a cart and at checkout, use the discountAutomaticBasicCreate mutation.


•mutation

Updates an amount off discount that's applied on a cart and at checkout when a customer enters a code. Amount off discounts can be a percentage off or a fixed amount off.


Note

To update discounts that are automatically applied on a cart and at checkout, use the discountAutomaticBasicUpdate mutation.


•mutation

Creates a buy X get Y discount (BXGY) that's applied on a cart and at checkout when a customer enters a code.


Note

To create discounts that are automatically applied on a cart and at checkout, use the discountAutomaticBxgyCreate mutation.


•mutation

Updates a buy X get Y discount (BXGY) that's applied on a cart and at checkout when a customer enters a code.


Note

To update discounts that are automatically applied on a cart and at checkout, use the discountAutomaticBxgyUpdate mutation.


•mutation

Temporarily suspends a code discount without permanently removing it from the store. Deactivation allows merchants to pause promotional campaigns while preserving the discount configuration for potential future use.

For example, when a flash sale needs to end immediately or a discount code requires temporary suspension due to inventory issues, merchants can deactivate it to stop new redemptions while keeping the discount structure intact.

Use DiscountCodeDeactivate to:

  • Pause active promotional campaigns timely
  • Temporarily suspend problematic discount codes
  • Control discount availability during inventory shortages
  • Maintain discount history while stopping usage

Deactivated discounts remain in the system and can be reactivated later, unlike deletion which persistently removes the code. Customers attempting to use deactivated codes will receive appropriate error messages.

•mutation

Creates an free shipping discount that's applied on a cart and at checkout when a customer enters a code.


Note

To create discounts that are automatically applied on a cart and at checkout, use the discountAutomaticFreeShippingCreate mutation.


•mutation

Updates a free shipping discount that's applied on a cart and at checkout when a customer enters a code.


Note

To update a free shipping discount that's automatically applied on a cart and at checkout, use the discountAutomaticFreeShippingUpdate mutation.



Was this section helpful?