Skip to main content

Discounts API

The Discounts API provides read-only access to discount codes and discount allocations applied to an order on the Order status page. Use this API to read which discounts were applied, how much was discounted, and whether each was a code, automatic, or custom discount from a Shopify Function.

  • 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 shopify global object provides the discount codes and discount allocations applied to the order. Access the following properties on shopify to read which discounts were applied and how much was discounted.

Anchor to discountAllocations
discountAllocations
<[]>
required

The cart-level discount allocations applied to the order. A discount allocation represents how a discount is distributed across the order. Each allocation includes the discounted amount and one of the following types:

  • CartCodeDiscountAllocation: A discount the buyer applied by entering a code at checkout.
  • CartAutomaticDiscountAllocation: A discount the merchant configured in Shopify admin to apply automatically.
  • CartCustomDiscountAllocation: A discount created programmatically by a Shopify Function.

Returns order-level discounts only. For per-line discount allocations, read from individual cart lines via the Cart Lines API.

Anchor to discountCodes
discountCodes
<[]>
required

A list of discount codes that the buyer entered during checkout and that were applied to the order.


  • Check both properties for a complete picture: discountCodes lists the codes entered by the buyer, while discountAllocations shows the actual amounts discounted. A single code can result in multiple allocations across different line items.

  • 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 data alone.

Was this page helpful?