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.
Anchor to Use casesUse cases
- 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.
Supported targets
- customer-account.
order-status. announcement. render - customer-account.
order-status. block. render - customer-account.
order-status. cart-line-item. render-after - customer-account.
order-status. cart-line-list. render-after - customer-account.
order-status. customer-information. render-after - customer-account.
order-status. fulfillment-details. render-after - customer-account.
order-status. payment-details. render-after - customer-account.
order-status. return-details. render-after - customer-account.
order-status. unfulfilled-items. render-after - customer-account.
order. page. render
Supported targets
- customer-account.
order-status. announcement. render - customer-account.
order-status. block. render - customer-account.
order-status. cart-line-item. render-after - customer-account.
order-status. cart-line-list. render-after - customer-account.
order-status. customer-information. render-after - customer-account.
order-status. fulfillment-details. render-after - customer-account.
order-status. payment-details. render-after - customer-account.
order-status. return-details. render-after - customer-account.
order-status. unfulfilled-items. render-after - customer-account.
order. page. render
Anchor to PropertiesProperties
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 discountAllocationsdiscountAllocationsdiscountAllocationsStatefulRemoteSubscribable<CartDiscountAllocation[]>StatefulRemoteSubscribable<CartDiscountAllocation[]>requiredrequired
The order-level discount allocations, including code-based, automatic, and custom discounts. Each allocation includes the discounted amount and the discount source.
- Anchor to discountCodesdiscountCodesdiscountCodesStatefulRemoteSubscribable<CartDiscountCode[]>StatefulRemoteSubscribable<CartDiscountCode[]>requiredrequired
The discount codes that the buyer applied to the order at checkout.
CartDiscountAllocation
A discount allocation applied to the order or a line item. There are three types: - `CartCodeDiscountAllocation`: A discount applied via a code entered by the buyer. - `CartAutomaticDiscountAllocation`: An automatic discount applied by Shopify based on merchant-configured rules. - `CartCustomDiscountAllocation`: A custom discount applied by a Shopify Script or discount function.
CartCodeDiscountAllocation | CartAutomaticDiscountAllocation | CartCustomDiscountAllocationCartCodeDiscountAllocation
- code
The discount code that the buyer entered at checkout.
string - discountedAmount
The monetary amount deducted from the order by this discount allocation.
Money - type
The type of discount allocation. Always `'code'` for code-based discounts.
'code'
Money
- amount
The decimal money amount, such as `29.99`.
number - currencyCode
The [ISO 4217](https://www.iso.org/iso-4217-currency-codes.html) currency code.
CurrencyCode
CurrencyCode
'AED' | 'AFN' | 'ALL' | 'AMD' | 'ANG' | 'AOA' | 'ARS' | 'AUD' | 'AWG' | 'AZN' | 'BAM' | 'BBD' | 'BDT' | 'BGN' | 'BHD' | 'BIF' | 'BMD' | 'BND' | 'BOB' | 'BOV' | 'BRL' | 'BSD' | 'BTN' | 'BWP' | 'BYN' | 'BZD' | 'CAD' | 'CDF' | 'CHE' | 'CHF' | 'CHW' | 'CLF' | 'CLP' | 'CNY' | 'COP' | 'COU' | 'CRC' | 'CUC' | 'CUP' | 'CVE' | 'CZK' | 'DJF' | 'DKK' | 'DOP' | 'DZD' | 'EGP' | 'ERN' | 'ETB' | 'EUR' | 'FJD' | 'FKP' | 'GBP' | 'GEL' | 'GHS' | 'GIP' | 'GMD' | 'GNF' | 'GTQ' | 'GYD' | 'HKD' | 'HNL' | 'HRK' | 'HTG' | 'HUF' | 'IDR' | 'ILS' | 'INR' | 'IQD' | 'IRR' | 'ISK' | 'JMD' | 'JOD' | 'JPY' | 'KES' | 'KGS' | 'KHR' | 'KMF' | 'KPW' | 'KRW' | 'KWD' | 'KYD' | 'KZT' | 'LAK' | 'LBP' | 'LKR' | 'LRD' | 'LSL' | 'LYD' | 'MAD' | 'MDL' | 'MGA' | 'MKD' | 'MMK' | 'MNT' | 'MOP' | 'MRU' | 'MUR' | 'MVR' | 'MWK' | 'MXN' | 'MXV' | 'MYR' | 'MZN' | 'NAD' | 'NGN' | 'NIO' | 'NOK' | 'NPR' | 'NZD' | 'OMR' | 'PAB' | 'PEN' | 'PGK' | 'PHP' | 'PKR' | 'PLN' | 'PYG' | 'QAR' | 'RON' | 'RSD' | 'RUB' | 'RWF' | 'SAR' | 'SBD' | 'SCR' | 'SDG' | 'SEK' | 'SGD' | 'SHP' | 'SLL' | 'SOS' | 'SRD' | 'SSP' | 'STN' | 'SVC' | 'SYP' | 'SZL' | 'THB' | 'TJS' | 'TMT' | 'TND' | 'TOP' | 'TRY' | 'TTD' | 'TWD' | 'TZS' | 'UAH' | 'UGX' | 'USD' | 'USN' | 'UYI' | 'UYU' | 'UYW' | 'UZS' | 'VES' | 'VND' | 'VUV' | 'WST' | 'XAF' | 'XAG' | 'XAU' | 'XBA' | 'XBB' | 'XBC' | 'XBD' | 'XCD' | 'XDR' | 'XOF' | 'XPD' | 'XPF' | 'XPT' | 'XSU' | 'XTS' | 'XUA' | 'XXX' | 'YER' | 'ZAR' | 'ZMW' | 'ZWL'CartAutomaticDiscountAllocation
- discountedAmount
The monetary amount deducted from the order by this discount allocation.
Money - title
The merchant-defined title of the automatic discount, such as "Buy 2 Get 1 Free".
string - type
The type of discount allocation. Always `'automatic'` for automatic discounts.
'automatic'
CartCustomDiscountAllocation
- discountedAmount
The monetary amount deducted from the order by this discount allocation.
Money - title
The title of the custom discount applied by a Shopify Script or discount function.
string - type
The type of discount allocation. Always `'custom'` for custom discounts.
'custom'
CartDiscountCode
- code
The discount code string entered by the buyer at checkout.
string
Anchor to Best practicesBest practices
- Distinguish discount types: Use the
typefield on each allocation to differentiate between'code','automatic', and'custom'discounts. - Use allocations for savings totals: Sum the
discountedAmountacross all allocations to calculate total savings. Don't rely on discount codes alone, as automatic and custom discounts don't have codes.
Anchor to LimitationsLimitations
- Per-line discount allocations are available on individual cart lines through the Cart Lines API, not through this API. The
discountAllocationsproperty 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.