Item cart price and compare price duplicating if there's more than one variant

New Member
1 0 0

This being in the cart page, I have a code to show the product price and then the compare price next to it, but if I have multiple variants, say black and Tall, these show 2 times next to each variant.

How can I stop the prices showing more than once despite the number of variants?

This is my code:


{% assign beforePrice = priceCompare | times: item.quantity %}
<dd><span>{{ item.variant.options[forloop.index0] }}</span></dd>
<span class="price-inline">
{{ item.product.price[forloop.index0] }}
{% if item.product.compare_at_price > item.product.price %}
<span class="before-price"> {{ beforePrice | money }} </span>
{% endif %}