The `DiscountCodeApp` object stores information about code discounts
that are managed by an app using
[Shopify Functions](https://shopify.dev/docs/apps/build/functions).
Use `DiscountCodeApp` when you need advanced, custom, or
dynamic discount capabilities that aren't supported by
[Shopify's native discount types](https://help.shopify.com/manual/discounts/discount-types).
Learn more about creating
[custom discount functionality](https://shopify.dev/docs/apps/build/discounts/build-discount-function).
> Note:
> The [`DiscountAutomaticApp`](https://shopify.dev/docs/api/admin-graphql/latest/objects/DiscountAutomaticApp)
object has similar functionality to the `DiscountCodeApp` object, with the exception that `DiscountAutomaticApp`
stores information about automatic discounts that are managed by an app using Shopify Functions.
Access Scopes
Apps must have `read_discounts` access scope.
Fields
appDiscountType:
AppDiscountType! -
The details about the app extension that's providing the
[discount type](https://help.shopify.com/manual/discounts/discount-types).
This information includes the app extension's name and
[client ID](https://shopify.dev/docs/apps/build/authentication-authorization/client-secrets),
[App Bridge configuration](https://shopify.dev/docs/api/app-bridge),
[discount class](https://help.shopify.com/manual/discounts/combining-discounts/discount-combinations),
[function ID](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries),
and other metadata about the discount type, including the discount type's name and description.
asyncUsageCount:
Int! -
The number of times that the discount has been used.
For example, if a "Buy 3, Get 1 Free" t-shirt discount
is automatically applied in 200 transactions, then the
discount has been used 200 times.
This value is updated asynchronously. As a result,
it might be lower than the actual usage count until the
asynchronous process is completed.
codesCount:
Count -
The number of codes that a customer can use to redeem the discount.
combinesWith:
DiscountCombinesWith! -
The
[discount classes](https://help.shopify.com/manual/discounts/combining-discounts/discount-combinations)
that you can use in combination with
[Shopify discount types](https://help.shopify.com/manual/discounts/discount-types).
createdAt:
DateTime! -
The date and time when the discount was created.
customerSelection:
DiscountCustomerSelection! -
The customers that can use the discount.
discountClass:
DiscountClass! -
The
[discount class](https://help.shopify.com/manual/discounts/combining-discounts/discount-combinations)
that's used to control how discounts can be combined.
discountId:
ID! -
The [globally-unique ID](https://shopify.dev/docs/api/usage/gids)
for the discount.
endsAt:
DateTime -
The date and time when the discount expires and is no longer available to customers.
For discounts without a fixed expiration date, specify `null`.
errorHistory:
FunctionsErrorHistory -
The [error history](https://shopify.dev/docs/apps/build/functions/monitoring-and-errors)
for the latest version of the discount type that the app provides.
hasTimelineComment:
Boolean! -
Whether there are
[timeline comments](https://help.shopify.com/manual/discounts/managing-discount-codes#use-the-discount-timeline)
associated with the discount.
recurringCycleLimit:
Int -
The number of billing cycles for which the discount can be applied,
which is useful for subscription-based discounts. For example, if you set this field
to `3`, then the discount only applies to the first three billing cycles of a
subscription. If you specify `0`, then the discount applies indefinitely.
shareableUrls:
DiscountShareableUrl! -
A list of URLs that the app can use to share the discount.
startsAt:
DateTime! -
The date and time when the discount becomes active and is available to customers.
status:
DiscountStatus! -
The status of the discount that describes its availability,
expiration, or pending activation.
title:
String! -
The discount's name that displays to merchants in the Shopify admin and to customers.
totalSales:
MoneyV2 -
The total sales from orders where the discount was used.
updatedAt:
DateTime! -
The date and time when the discount was updated.
usageLimit:
Int -
The maximum number of times that a customer can use the discount.
For discounts with unlimited usage, specify `null`.
discountCodeAppCreate
Creates a code discount. The discount type must be provided by an app extension that uses [Shopify Functions](https://shopify.dev/docs/apps/build/functions). Functions can implement [order](https://shopify.dev/docs/api/functions/reference/order-discounts), [product](https://shopify.dev/docs/api/functions/reference/product-discounts), or [shipping](https://shopify.dev/docs/api/functions/reference/shipping-discounts) discount functions. Use this mutation with Shopify Functions when you need custom logic beyond [Shopify's native discount types](https://help.shopify.com/manual/discounts/discount-types).
For example, use this mutation to create a code discount using an app's "Volume" discount type that applies a percentage off when customers purchase more than the minimum quantity
of a product. For an example implementation, refer to [our tutorial](https://shopify.dev/docs/apps/build/discounts/build-discount-function).
> Note:
> To create automatic discounts with custom logic, use [`discountAutomaticAppCreate`](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticAppCreate).
discountCodeAppUpdate
Updates a code discount, where the discount type is provided by an app extension that uses [Shopify Functions](https://shopify.dev/docs/apps/build/functions). Use this mutation when you need advanced, custom, or dynamic discount capabilities that aren't supported by [Shopify's native discount types](https://help.shopify.com/manual/discounts/discount-types).
> Note:
> To update automatic discounts, use [`discountAutomaticAppUpdate`](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticAppUpdate).
DiscountCode
The type of discount associated with the discount code. For example, the discount code might offer a basic discount of a fixed percentage, or a fixed amount, on specific products or the order. Alternatively, the discount might offer the customer free shipping on their order. A third option is a Buy X, Get Y (BXGY) discount, which offers a customer discounts on select products if they add a specific product to their order.