Discounts

Discounts can be applied at the line item or cart/checkout/order level, meaning that they apply directly to specific line items, or apply to the cart as a whole. They can come from one of the following sources:

Discounts from each source have a discount_application, which registers the discount on the cart, checkout, or order. If any discounts are line item-specific, a discount_allocation is created for each associated line item to register any discount_applications with the line item.

Given that discounts can apply directly to line items or the cart as a whole, there are two areas where you should display discount information:

Display line item discounts

If a discount applies to specific line items, then it should be displayed with those items. This display has two aspects:

The following is an example of outputting the price and discounts display:

Line 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:

  • original_price
  • original_line_price
  • final_price
  • final_line_price

Refer to the example from the previous section to learn how these are used.

Line 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. The 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.

Refer to the example from the previous section to learn how these are used.

Display cart 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. Because of this, 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 object.

For example: