Calculating the sum of item variant metafields in the cart

I figured this out…

{%- assign length_cm = 0 -%}
{%- for item in cart.items -%}
    {%- assign length_cm = length_cm | plus: item.variant.metafields.product_data.length_cm | times: item.quantity -%}
{%- endfor -%}

Note the addition of ‘times: item.quantity’ to the end. This now calculates the length times the line quantity.

Thanks, @LitCommerce for the help.

1 Like