Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hello,
I was able to add item price on the packing slip with the code below, but it shows ALL prices under each item (repetitive).
Can you please help on adding prices & weight on the packing slip?
{% for item in order.line_items %}
{% if item.sku == line_item.sku %}
<span class="line-item-description-line">
{{ item.final_price | money }}
</span>
{% endif %}
{% endfor %}
Hi @Amir212
You can try one of them:
{% for item in order.line_items %} {% if item.sku != line_item.sku %} <span class="line-item-description-line"> {{ item.final_price | money }} {{ item.weight | weight }} </span> {% endif %} {% endfor %}
or
{% for item in order.line_items %} {% if item.sku != prev_sku %} <tr> <td>{{ item.final_price | money }}</td> <td>{{ item.weight }}</td> </tr> {% set prev_sku = item.sku %} {% endif %} {% endfor %}
I hope it helps @Amir212 !
If our suggestions are useful, please let us know by giving it a like, marking it as a solution, or donating here ☕.
Product Labels by BSS | B2B Solution & Custom Pricing
Need help from our expert? Kindly share your request with us via community@bsscommerce.com
Hello,
Thank you for the input, but both didn't work.
I was able to add item price with this code (just in case anyone else needs to):
</p>
{% assign final_price = nil %}
{% assign line_name = line_item.title %}
{% if line_item.variant_title != blank %}
{% assign line_name = line_name | append: " - " | append: line_item.variant_title %}
{% endif %}
{% for item in order.line_items %}
{% assign order_name = item.title %}
{% if order_name == line_name %}
{% assign final_price = item.final_price %}
{% endif %}
{% endfor %}
{% if final_price %}
{{ final_price | money }}
{% endif %}
</div>
If anyone can help with adding the weight that would be great!
Hey @Amir212 ,
When I follow this Shopify documentation: https://shopify.dev/docs/api/liquid/objects/line_item
I realize that you can retrieve the weight by using the variant's weight property.
Here's the code snippet:
{% assign final_price = item.final_price %} {% assign weight = item.variant.weight %} {{ weight }}
I hope this helps! If it works for you, please mark it as a solution. I am very happy for that. Have a great day!
If our suggestions are useful, please let us know by giving it a like, marking it as a solution, or donating here ☕.
Product Labels by BSS | B2B Solution & Custom Pricing
Need help from our expert? Kindly share your request with us via community@bsscommerce.com
Can you please tell me the exact place in the template where we should put this code?
I'd like to know this too, please. I am having a hard time showing the weight. It just says 0.0 oz all the time and also that quantity does not line up. Please help.