Liquid objects for scripts

The scripts feature exposes some new Liquid object attributes that you can use to show information for scripts and discounts on your store.

Cart objects

You might also want to refer to the general documentation for cart.

cart.total_discount

Returns the total of all discounts (the amount saved) for the cart.

cart.original_total_price

Returns the original total price of the cart before discounts were applied.

Line item objects

You might also want to refer to the general documentation for line_item.

line_item.discounts

Returns any discount applied to the line item by a script.

line_item.message

Returns the discount message if any discounts have been applied to the line item by a script.

line_item.original_price

Returns the original price of the line item before discounts were applied.

line_item.original_line_price

Returns the original line price of the line item before discounts were applied.

line_item.total_discount

Returns the total amount of all discounts applied to the line item.

Example

You can use Liquid to show the discounts for each line item:


{% if item.original_line_price != item.line_price %}
  <small class="original-price"><s>{{ item.original_line_price | money }}</s></small>
{% endif %}
{{ item.line_price | money }}
{% for discount in item.discounts %}
  <small class="discount">{{ discount.title }}</small>
{% endfor %}

Want to discuss this page?

Visit the Shopify Community

Ready to start selling online with Shopify?

Try it free