I want to make it look like these based on the product tags. So I want to be able to style them based on like tag of pink for the Rose one. Is this possible? I tried some things, but it either changed
@shellbell
Nice idea.
It can be done.
The first step would be to define some colors using CSS. Then get all the tags of a product, if we find the tag we are looking for, we can add it as a class to the product card, or add a new class.
For instance, let’s say we add a “pink” tag to a product. If we find that tag, we would add the “pink” class to the product card.
Like this :
{% for product in collection.products %}
{% if product.tags contains 'pink' %}
{% else %}
{% endif %}
{% endfor %}
I hope it helps. I might not use tag personally. I would use a metafield but it’s up-to you.
I want to put it in the card-product not main product as I want it for the product grids in things like collections. I have tried the following, closest thing to work but changes everything, anything else I tried changes nothing.
How would you use a metafield to do this? I have used for various things but never a background color for product card. I did use it to change the main product picture already though, but unsure how to set that as a background color.