I am attempting to display the highest price and it’s related image for a product on a collection page. I have the below code in place just to target the price. But it is returning a div with the highest price for every product in the collection listed underneath the product I am trying to target. I only want the product price and image to be displayed once per product. I can’t see my mistake - help.
{% if collection.handle == 'stock-up-boxes' %}
{% for product in collection.products %}
{% assign max_price_variant = product.variants.first %}
{% assign max_price = max_price_variant.price %}
{% for variant in product.variants %}
{% if variant.price > max_price %}
{% assign max_price_variant = variant %}
{% assign max_price = variant.price %}
{% endif %}
{% endfor %}
{{ max_price | money }}
{% endfor %}
{% endif %}

