The Order Discount API enables you to create a new type of discount that is applied to all merchandise in the cart. ## Example use cases - Money off the order subtotal. For example, $5 off the order subtotal. - Money off products on an order. For example, 20% off all products on the order. - Tiered discount by spend. For example, spend $100 get 10% off all products. ## Developer tools and resources <div class="resource-card-grid"> <div> <a class="resource-card" href="/docs/apps/build/cli-for-apps" data-theme-mode=""> <div class="resource-card__indicator-container"><img src="/assets/resource-cards/cli" data-alt-src="/assets/resource-cards/cli-dark" aria-hidden="true" class="resource-card__icon themed-image"></div> <h3 class="resource-card__title"> Shopify CLI </h3> <p class="resource-card__description">A command-line tool for building Shopify apps.</p> </a> </div></p> <p><div> <a class="resource-card" href="/docs/api/functions/reference/order-discounts/graphql" data-theme-mode=""> <div class="resource-card__indicator-container"><img src="/assets/resource-cards/graphql" data-alt-src="/assets/resource-cards/graphql-dark" aria-hidden="true" class="resource-card__icon themed-image"></div> <h3 class="resource-card__title"> Order Discount API reference </h3> <p class="resource-card__description">Consult the GraphQL reference for the Order Discount API.</p> </a> </div> </div> ## Migrating from scripts to functions If you want to migrate an existing [line item script](https://help.shopify.com/manual/checkout-settings/script-editor/shopify-scripts) to Shopify Functions, then you can use the following mappings: | Shopify Scripts method | Description | Shopify Functions object | Additional context | | ------------ | ----------- |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -------------- | | `change_line_price` | Applies a discount to a cart line for a product by specifying a new reduced price, and a message | [Product discount](/docs/api/functions/reference/product-discounts/graphql/functionrunresult) | Apply one or more [Discounts](/docs/api/functions/reference/product-discounts/graphql/common-objects/discount) by specifying the [Value](/docs/api/functions/reference/product-discounts/graphql/common-objects/value) (`percentage` or `fixedAmount` off), [Target(s)](/docs/api/functions/reference/product-discounts/graphql/common-objects/target) (either a `cartLine`, or `productVariant`), and an optional message. | `split` | Splits a product into multiple lines so that you can apply discounts to partial quantities | [Product discount](/docs/api/functions/reference/product-discounts/graphql/functionrunresult) | Use the optional `quantity` field in [Target](/docs/api/functions/reference/product-discounts/graphql/common-objects/target) (either a `cartLine`, or `productVariant`) to optionally limit the number of units the discount may be applied to. | | `change_properties` | Adds or changes a line item property | Not available | Refer to [applyAttributeChange](/docs/api/checkout-ui-extensions/latest/apis) in the checkout UI extensions API to apply attribute changes. | | `reject` | Disallows a discounts code from being applied at checkout | Not available | Use a [Product discount](/docs/api/functions/reference/product-discounts/graphql/functionrunresult) or [Order discount](/docs/api/functions/reference/order-discounts/graphql/functionrunresult) function that contains the necessary logic. For example, you can use conditions to exclude a discount from applying. | ## Limitations and considerations - Input `cart.deliveryGroups` is always an empty array for this function. - Active automatic app discounts using Shopify Functions are applicable for all [Shopify sales channels](https://help.shopify.com/manual/online-sales-channels) that use Shopify Checkout, including the [Online Store](https://help.shopify.com/manual/online-store) and [Shopify Point Of Sale (POS)](https://help.shopify.com/manual/sell-in-person). ## Next steps - Learn how to use Shopify Functions by [building a discounts experience](/docs/apps/build/discounts).