Skip to main content
Migrate to Polaris

Version 2025-07 is the last API version to support React-based UI components. Later versions use web components, native UI elements with built-in accessibility, better performance, and consistent styling with Shopify's design system. Check out the migration guide to upgrade your extension.

Discounts API

The Discounts API provides the discount codes and discount allocations applied to the order. Use it to display applied discounts or calculate total savings on the Order status page.

  • Display applied discount codes: Show the discount codes the buyer entered during checkout.
  • Show discount breakdowns: Display the amount saved through each discount, whether it was a code, an automatic discount, or a custom discount from a Shopify Function.

The Discounts API object provides discount codes and allocations from the order. Access the following properties on the API object to read discount data.

Anchor to discountAllocations
discountAllocations
StatefulRemoteSubscribable<[]>
required

The order-level discount allocations, including code-based, automatic, and custom discounts. Each allocation includes the discounted amount and the discount source.

Anchor to discountCodes
discountCodes
StatefulRemoteSubscribable<[]>
required

The discount codes that the buyer applied to the order at checkout.


  • Distinguish discount types: Use the type field on each allocation to differentiate between 'code', 'automatic', and 'custom' discounts.
  • Use allocations for savings totals: Sum the discountedAmount across all allocations to calculate total savings. Don't rely on discount codes alone, as automatic and custom discounts don't have codes.

  • Per-line discount allocations are available on individual cart lines through the Cart Lines API, not through this API. The discountAllocations property on the Discounts API returns only order-level discounts.
  • Discount allocations show the discounted amount, but not the original discount configuration. You can't determine whether a discount was a percentage or fixed amount from the allocation alone.

Was this page helpful?