Display Weight on COLLECTION page?

GeorgeMcG
Shopify Partner
5 0 1

I am currently working on a clients Shopify site. They have requested that the product weight, for each individual product, is pulled through and displayed next to the price on collection pages.

 

I can't find any documentation either specifically about this, or that as I understand it, would allow me to achieve this.

If I use {{ product.weight | weight_in_units }} in the partial that is pulled through to show my products on the collection page, it shows 0.0lbs, as I assume it's trying to pull the weight on the collection page itself, which of course doesn't exists and is therefore 0. What I'm trying to achieve is showing each products weight under the product in the collection.

Is there any assistance you can provide, or even point me in the direction of the correct documentation?

 

Any help would be greatly appreciated.

0 Likes
Jasoliya
Shopify Expert
4210 569 1032
Hi,
Please use this if it help you to show weight.
{{ product.variants.first.weight | weight_with_unit }}
Let me know if you need help
Want to modify or custom changes on store hire me.
If helpful then please Like and Accept Solution.
Email: jasoliyabrijesh123@gmail.com Or WhatsApp Or Skype: jasoliya.brijesh
Want to get Free review and advice for sale on store ?? just text me here
0 Likes
SWSolutions
Trailblazer
193 25 47

 

{% for variant in product.variants %} 
{{ variant.weight | weight_with_unit }}
{% endfor %}

For Design, Development and custom changes Hire Me.
If your problem solved then Like & Accept this Solution.
Email ID: silencewebsolutions@gmail.com
0 Likes
KiwiDesigner
Tourist
9 0 1

Hi,

 

Thanks for the info so far.  I can get the weight displaying on all products in kg.

However, I have a slightly more complex requirement.

 

I would like to display product weight in grams, and ONLY when a product weight has been added (this could be done by adding some code saying if the product weight is zero, don't display?)

 

Any help would be greatly appreciated - thanks in advance!

0 Likes
Jasoliya
Shopify Expert
4210 569 1032

You can change your unit from admin product to gram and then add this code in snippet->product-grid.liquid file at bottom:

{% if product.variants.first.weight > 0%}

 { { product.variants.first.weight | weight_with_unit }}
{% endif %}

Want to modify or custom changes on store hire me.
If helpful then please Like and Accept Solution.
Email: jasoliyabrijesh123@gmail.com Or WhatsApp Or Skype: jasoliya.brijesh
Want to get Free review and advice for sale on store ?? just text me here
0 Likes
KiwiDesigner
Tourist
9 0 1

Hello and thanks for your message.

Unfortunately this didn't help.  

 

Firstly, I don't have a file named product-grid.liquid

 

Secondly I want the weight to be shown next to the product name on the collection page.

 

For example Product Name (250g)

 

Cheers,


Wayne

KiwiDesigner
Tourist
9 0 1

Actually I fixed this using a combination of code on this page and inserted it next to the product name - worked well.

 

{% for variant in product.variants %}
    {% if product.variants.first.weight > 0%}
        {{ variant.weight | weight_with_unit }}
    {% endif %}
{% endfor %}

 

Thanks again!

0 Likes
GeorgeMcG
Shopify Partner
5 0 1

The solution I found to this contained two parts:

 

Adding in a New Meta Field using an app, and then pulling that info through in the correct place.

 

Your template name may well be different, for me the Collection Card info is held in a template called: partial--product.liquid

 

Add a new meta tag with

Namespace: global

Key: display_weight (or any identifier of your choice)

Value: [Enter Weight & Measurement here]

 

I then used the following code in my desired place to pull through that information:

<span class="collection_weight">{{ product.metafields['global']['display_weight'] }} </span>

 

Style .collection_weight however you see fit. This method lets you control when it appears (if it's blank, it no content appears), and it's measurement. As the meta field is a string you just type in grams instead of kg. The drawback is that this isn't dynamic, but I wouldn't think you would/should be changing the weight of the same product constantly.

 

My result:

Screenshot 2020-05-04 at 11.23.59.png

 

 

 

0 Likes
Hemant_Chauhan
Shopify Partner
17 0 2

Hi,

i have the same issue , can you please tell me in details how can i show my product weight in collection page.

& which app you are talking about?

 

0 Likes
Jasoliya
Shopify Expert
4210 569 1032

You can try this code on collection page grid.

Snippet->product-grid file

{% if product.variants.first.weight > 0%}

 { { product.variants.first.weight | weight_with_unit }}
{% endif %}

Want to modify or custom changes on store hire me.
If helpful then please Like and Accept Solution.
Email: jasoliyabrijesh123@gmail.com Or WhatsApp Or Skype: jasoliya.brijesh
Want to get Free review and advice for sale on store ?? just text me here
0 Likes