Shopify themes, liquid, logos, and UX
I want to add the product weight in gr. next the product price.
I tried after reading another question by adding <p>{{ variant.weight }}</p> in featured -product.liquid, but didn't work.
Anyone knows how I can do it?
Thanks
Solved! Go to the solution
This is an accepted solution.
@grubio, I just checked your website. You were adding it to featured product and not collection. Add this code to Snippets -> product-card-list.liquid:
Find this div ---> <div class="product-card__price-wrapper">
{% render 'product-price-listing', product: product %}
{% render 'product-price', variant: product.selected_or_first_available_variant, product: product, wrapper_class: 'price--listing price--variants' %}
<a href="{{ product.url }}" class="rte product-card__view-details" data-product-card-link>
{{ 'products.product.view_details' | t }}
</a>
</div> <---- add weight after this div
{{ product.variants.first.weight | weight_with_unit }}
Hi @grubio
What theme are you using? Where did you paste the piece of code? Are you products variant dependent or just one version is available?
Hi @JHKCreate
I'm using Express Theme.
Below {% render 'product-price', variant: current_variant, product: product, show_vendor: section.settings.show_vendor %}
Only 1 version.
Thanks!
Add this code:
{{ product.variants.first.weight | weight_with_unit }}
Hi @g33kgirl
Thanks for your reply.
I added the snipped code in the same place and I cannot see the weight yet.
Section-> featured -product.liquid
Below -> {% render 'product-price', variant: current_variant, product: product, show_vendor: section.settings.show_vendor %}
Any other idea?
@grubio, that should have worked. Try this:
<p>{{ current_variant.weight }}</p>
Hi @g33kgirl
It doesn't. I should do something wrong then.
Probably I'm not adding the code in the right place
I installed the Express Theme on my development store and it shows the weight on featured-product section on homepage:
Have you added the featured-product section component on your homepage?
Thanks @g33kgirl
I don't see what I do wrong.
The code is the same in the same place:
I have a weight for this product
Which I can see in the product page (in kg, what I think this another issue)
But in the featured collection
I tried a different browser because the cache and on... and nothing. Doesn't work.
Any idea?
Thanks a lot!!!!
Are you adding this section to your homepage?
Hi @g33kgirl
I have a Featured Product section and Featured Collection in my homepage. I'm not adding a new one, should I do that?
Thanks
No. Have you added the code to both Featured collection and Featured Product liquid files?
I had it in Featured Product liquid files. Now, I added it in both. In Featured Product in the same line that you had. For featured collected, I tried to guess the best place.
However, it didn't work.
{{ product.variants.first.weight | weight_with_unit }}
That is really strange. Can you share your website url?
Lovejamon.com
hola123
This is an accepted solution.
@grubio, I just checked your website. You were adding it to featured product and not collection. Add this code to Snippets -> product-card-list.liquid:
Find this div ---> <div class="product-card__price-wrapper">
{% render 'product-price-listing', product: product %}
{% render 'product-price', variant: product.selected_or_first_available_variant, product: product, wrapper_class: 'price--listing price--variants' %}
<a href="{{ product.url }}" class="rte product-card__view-details" data-product-card-link>
{{ 'products.product.view_details' | t }}
</a>
</div> <---- add weight after this div
{{ product.variants.first.weight | weight_with_unit }}
That was the issue and solution.
Thanks a lot!
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024