Hi!
I am running a code to display color swatches on product pages, since all our color options are unique products. To do this, we use the product metafields to manually link products together, and run this code to display them on product pages.
The issue i now face is when all color options are sold out except 1, the
title im using is still displaying on that one product, even though there are no other color options available. In other words, the
is displayed, but not showing products, so ideally the
should also be hidden.
I have tried using the “product.available” condition, but that condition only seems to look at the availability for product your displaying, and not at the products within the metafield. Is the a liquid condition we can use to check if the products within the “product.metafields.custom.colorswatches” are available or not, so the colorswatch-code will only run if atleast one of the products within the metafield are available?
Here is an URL for a product with this issue: https://golfsenteret.no/products/original-penguin-heritage-water-repellent-track-jakke-herre-hvit
This is the code:
{% assign related_products = product.metafields.custom.colorswatches.value %}
{% if related_products %}
Finnes i flere farger:
{% for related_product in related_products %}
{{ related_product.price | money }}
{% endfor %}
{% endif %}