3.6 KiB
layout, title, nav
| layout | title | nav | ||
|---|---|---|---|---|
| default | line_item |
|
line_item
A line item represents a single line in the shopping cart. There is one line item for each distinct product variant in the cart.
The line_item object can be accessed in all Liquid templates, as well as in notification email templates, the Thank You page of the checkout, as well as in apps such as Order Printer.
The line_item object has the following attributes:
{% anchor_link "line_item.id", "line-id" %}
Returns the id of the line item, which is the same as the id of its variant.
{% anchor_link "line_item.product", "product" %}
Returns the product of the line item.
Example for getting a line item's image:
{% highlight html %}{% raw %} {{ line_item.product.featured_image | product_img_url | img_tag }} {% endraw %}{% endhighlight %}
{% anchor_link "line_item.variant", "variant" %}
Returns the variant of the line item.
{% anchor_link "line_item.title", "title" %}
Returns the title of this line item. line_item.title combines both the line item's product.title and the line item's variant.title, separated by a hyphen.
Input
Output
To output just the product title or variant title, you can access the title of the respective variables.
Input
Output
{% anchor_link "line_item.price", "price" %}
Returns the price of the line item's variant.
{% anchor_link "line_item.line_price", "line-price" %}
Returns the combined price of all the items in the line_item. This is the equivalent of line_item.price times line_item.quantity.
{% anchor_link "line_item.quantity", "quantity" %}
Returns the quantity of the line item.
{% anchor_link "line_item.grams", "grams" %}
Returns the weight of the line item. Use the weight_with_unit filter to format the weight.
{% anchor_link "line_item.sku", "sku" %}
Returns the SKU of the line item's variant.
{% anchor_link "line_item.vendor", "vendor" %}
Returns the vendor name of the line item's product.
{% anchor_link "line_item.requires_shipping", "requires-shipping" %}
Returns true if the line item requires shipping, or false if it does not. This is set in the variant options in the Products page of the Admin.
{% anchor_link "line_item.variant_id", "variant-id" %}
Returns the id of the line item's variant.
{% anchor_link "line_item.product_id", "product-id" %}
Returns the id of the line item's product.
{% anchor_link "line_item.fulfillment", "fulfillment" %}
Returns the fulfillment of the line item.