All things Shopify and commerce
Hi,
How to show weight in every products and total weight in cart for Craft theme?
I spend few days for trying to do this. But any code I found is not worked. Got really tired of this.
Can any one help to fix this?
Thank you in advance.
To display total weight on cart page add this code in your liquid file which is responsible for displaying cart page
{% assign totalWeight = 0 %}
{% for item in cart.items %}
{% assign productWeight = item.variant.weight | weight_with_unit %}
{% assign productQuantity = item.quantity %}
{% assign productTotalWeight = productWeight | times: productQuantity %}
{% assign totalWeight = totalWeight | plus: productTotalWeight %}
{% endfor %}
<p>Total Cart Weight: {{ totalWeight }}</p>
Hi Asad,
Thanks for the help. However, it only shows the number: Total Cart Weight: 2
And it shows in cart on the left side. Should be on the right.
Is there any way to show weight in every item card? Not only the total in the cart?
Yes you can show weight on each produt with unit by using this variable
{{ selected_variant.weight | weight_with_unit }}
Appears, but only zeros. Does not show weights.
And shows in the bottom left corner.
It should be displayed in a visible place, at the bottom of the size variations or similar.
I don't really understand coding. I am new to Shopify. So maybe I'm not uploading it where it should be.
Is there a way to make it at least add "kg" and show not only whole numbers after the decimal point?
If you'd like me to provide a more thorough examination of your store, I'll require collaborator access to effectively meet your needs.
How to make a "real-time" update of "Total Cart Weight" in this code?
For example, if you add quantity for the product in the cart, the total cart weight is not updated and you need to refresh the page. How to correct it?
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025