DiscountLine - Liquid Object Reference
On this page
Description
The DiscountLine object holds the total discount one promotion applied to a cart or order. Read a list of them from discount_breakdown_lines on the Cart or Order object to show each promotion as a separate row in a summary, instead of one combined discount total.
Each line totals the discount for one promotion across every item it applied to, including a shipping discount. Sale prices are not included, because they are not promotions.
In POS templates, such as a POS receipt template, discount_breakdown_lines is available on the Cart and Order objects with three differences:
- A line has
name,amount, andpoints, but noid. - A promotion that has since been deleted shows the name
Promotioninstead of an empty name. - A line whose total is zero or negative is left out, so the negative refund values described under Signs and refunds do not appear at POS.
Attributes
| Attribute | Type | Description |
|---|---|---|
amount |
Number | Returns the currency discount this promotion applied. 0 when the promotion discounted points only |
id |
String | Returns the Salesforce ID of the promotion (s_c__Promotion2__c). Use it as a stable key, for example in a data- attribute, because the name can change |
name |
String | Returns the display name of the promotion. Empty when the promotion has since been deleted |
points |
Number | Returns the points discount this promotion applied. 0 when the promotion discounted currency only |
Signs and refunds
On a sale, amount and points are positive numbers. On a refund order they are negative, because the line adds value back to what was returned. Multiply by -1 for display, so a sale shows as money off and a refund as money back.
Cart and order differences
- Cart — returns lines only when the store uses Promotions v2. On a store that still uses the original promotions,
current_cart.discount_breakdown_linesis always empty. - Order — always returns lines for the promotions applied when the order was placed, whichever promotions version the store uses now.
Example
Itemize promotions in a cart summary, showing a currency amount, a points amount, or both:
```liquid
{% for discount_line in current_cart.discount_breakdown_lines %}
{% endfor %} ```
For a cart where a promotion named “10% off shirts” took 15.00 off, the summary shows a “10% off shirts” row with the amount as a negative value in the store’s currency, such as -$15.00. The same loop works on an order confirmation page with current_order.discount_breakdown_lines.
Available on
- Cart - Liquid Object Reference —
discount_breakdown_lines - Order - Liquid Object Reference —
discount_breakdown_lines
Was this article helpful?
Thanks for your feedback! It helps us improve our docs.