Re: Show Selected variant weight on Product Page- Struggling with .js i guess

Show Selected variant weight on Product Page- Struggling with .js i guess

3 0 0

Hello all,


I try to show the variants weight on my product page cause i update my theme atm. Problem is that the way i did it before not working anymore and i wasnt able to figure out why. I started over but there are some strange things.


1. I tried to use  {{ variant.weight | weight_with_unit }} like before.

   Made a new snippet with code:

<div style="font-size: small;">
<p>Gewicht pro Artikel:
<span id="weightpreview">{{ current.variant.weight | weight_with_unit }}</span>


2. -> render the snipped at main-product.liquid at the place i wanted


3. Output: "Gewicht pro Artikel: 0.0"


If i paste the code directly somewhere at the bottom from main-product.liquid it shows the weight suddenly but not updating it when switching the variant. And before i go to my .js question i need to know why its not showing

at least the first weight when i render the snippet.


Hope its somehow understandable and anyone knows the trick or some link with infos.

Reply 1 (1)

1 0 0



I've got the same problem with dawn theme:


current.variant.weight doesn't work at all and shows 0 g.


product.selected_variant.weight works like

product.selected_or_first_available_variant.weight and like

product.variants.first.weight - it shows the weight of the first variant.


So I'm stuck at the moment. I use custom liquid.