Discounts
Discounts can be applied at the line item level, or the cart, checkout, or order level. This means that they apply directly to specific line items, or apply to the cart or order as a whole. Discounts can be applied in the following ways:
-
In this tutorial, you'll learn how to display discounts in your theme.

Anchor to RequirementsRequirements
You've created a cart template or a customers/order template.
Anchor to ResourcesResources
To display discounts in your theme, you'll use the following:
Anchor to The ,[object Object], objectThe discount_application object
discount_application objectThe discount_application object registers discounts at the cart, checkout, or order level. Depending on where you're implementing your discount display, you'll access the relevant discount applications through the associated parent object:
-
For the cart template:
-
For the customers/order template:
NoteManual discount codes can only be applied at the checkout, so they're not available through
cart.discount_applications.
Anchor to The ,[object Object], objectThe discount_allocation object
discount_allocation objectThe discount_allocation object associates a discount_application with a line item.
You can access an array of all of the discount allocations associated with a line item using line_item.line_level_discount_allocations.
Anchor to The ,[object Object], objectThe line_item object
line_item objectTo complete the price display, you need to use price and discount attributes of the line_item object, including:
Anchor to Implementing discount displaysImplementing discount displays
Because discounts can apply to line items or to the cart or order as a whole, you should display discount information in two places:
-
The examples in this tutorial use the cart template. However, you can adapt these examples to add discounts to the customers/order template by using the
orderobject where thecartobject is used.You can implement the components directly in a Liquid template, or in a section in a JSON template.
Anchor to Line item discountsLine item discounts
If a discount applies to specific line items, then it should be displayed with those items. To display discounts with line items, you need to include the following in your display:
Anchor to Line item priceLine item price
If a discount has been applied to a line item, then you should show the original price with a strikethrough, as well as the new discounted price. Each of these can be accessed with the following attributes of the Liquid line_item object:
Anchor to Line item discountsLine item discounts
If a discount has been applied to a line item, then you should show each discount that's applied, with its associated discount amount, or a total discount amount. Line item-specific discounts can be accessed through the line_level_discount_allocations attribute of the Liquid line_item object, and the total line item discount can be accessed through the line_level_total_discount attribute.
Anchor to ExampleExample
The following is an example that outputs the price and discounts display:

For another example of displaying line item discounts, you can refer to Dawn's implementation.
Anchor to Cart discountsCart discounts
The subtotal is the line item total after line item discounts have applied, and the total is the cart total after cart discounts have applied. If a discount applies to the cart as a whole, then it should display between the subtotal and total.
Cart-level discounts can be accessed through the cart_level_discount_applications attribute of the cart or order object.
Example

For another example of displaying cart discounts, you can refer to Dawn's implementation.