Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

product weight is not showing the correct amount

product weight is not showing the correct amount

YounesTimitar
Explorer
155 0 18

Hey

 

So I have one product with only 0.5  g (weight) but all the time it shows for 1g. Every other product the weight is over 1g and it shows correct but only for this one its 0.5g  but shows 1 g

YounesTimitar_0-1677155906996.png

 

 

 

YounesTimitar_1-1677155906999.png

 

 

 

I already asked my theme developer and they said that it has something to do with this code snippet a member of the shopify community changed for me. But they wont help me cause its not handle stuff like this. 

YounesTimitar_2-1677155907000.png

 

 

Replies 8 (8)

bytescoop
Shopify Partner
5 0 3

Hello @YounesTimitar 

Your code image is not clear but have you tried {{ variant.weight | weight_with_unit }} this code?

YounesTimitar
Explorer
155 0 18

Hey,

 

Where should I try this? I dont want to delete the current code because it was a costume code made by  a developer to show the product infos at a specific point and I want to keep that. 

bytescoop
Shopify Partner
5 0 3

@YounesTimitar you have to put this code where your weight code is now. Just make sure you assign a variant variable as per your theme's name. 
For eg., I gave you this code {{ variant.weight | weight_with_unit }} but your theme has currentVariant instead of variant. Thene your code is {{ currentVariant.weight | weight_with_unit }}

Still, if you are not comfortable with code editing, you can mail me at bytescoop.tech@gmail.com and I can help you with theme customization. 

Thank you!

YounesTimitar
Explorer
155 0 18

Hey, When I put this code in it shows 0 g for every product

bytescoop
Shopify Partner
5 0 3
Can you please allow me to edit your code? you can send me a store invite
on bytescoop.tech@gmail.com
YounesTimitar
Explorer
155 0 18

Can we try it like this first please.

 

This is the new code:

YounesTimitar_0-1677504522164.png

And now it shows 0g for every product:

YounesTimitar_1-1677504548825.png

 

bytescoop
Shopify Partner
5 0 3

@YounesTimitar you have to use the current_variant variable instead of currentVariant. 
I give you the currentVariant variable as an example. 
But this is not the working solution. I tried it in my store also and it has the same problem. 
Shopify auto rounds off the .5-gram value in their nearest number.  

YounesTimitar
Explorer
155 0 18

Hey, 

Thanks for your awnser, so what should I do now I didnt really understandyou.