Show the weight of all products in the cart with the same product's SKU or TAG

Show the weight of all products in the cart with the same product's SKU or TAG

Nekko
Visitor
3 1 1

Hello there Shopify society,

I need an advice regarding the cart's product's weight.
I need to show the message to customers if the go over the limit for certain products.
I managed to show the message if each product's weight with SKU E1 go over 1000g, but I need to show the message if the weight of all products in the cart with SKU 'E1' have more than 1000g.
How can I show that, I tried with {{cart.total_weight}} , but it show the weight of all products, not only total product of items with SKU 'E1'? I would really appreciate if you could help me. I tried some apps, but they don't work.

Thanks

 

{% if item.variant.sku contains 'E1'%}

{%if item_weight_cart < 1000 %}
<p style="color: red;"> This item is considered to be a Dangerous good.</p>
{%endif%}
{%if item_weight_cart > 1000 %}
<p style="color: red;"> You have some Dangerous good items in your cart .<br> You have reached the limit for Dangerous good items. Please, lower the quantity.</p>

{%if cart.total_weight > 1000 %}
<p style="color: red;"> The total weight of all items with E1 regulation is over the limit, please lower the quantity. </p>
{%endif%}

{%endif%}

 

Reply 1 (1)

afcompany
Shopify Partner
16 0 9

I am sure this is a bit late... But I was looking for something similar and came up with this solution:

 

Depending on your version of shopify theme... But on the cart page, before if displays each item: we wanted to trigger a custom quote for for items that would weigh more than UPS would allow (150 pounds)

 

{% for item in cart.items %}
  {% capture itemUnitWeight %}{{item.grams | divided_by: 453.592}}{% endcapture %}
  {% capture itemTotalWeight %}{{ itemUnitWeight | times: item.quantity }}{% endcapture %}
  {% if itemTotalWeight > 149 %}
    {% assign requires_quote = true %}
  {% endif %}

  ...