Can I create an if statement on the Product.html page depending on the category which a product belongs to? Something like this:
{% if product.category.name == 'Shirts' %}
<div>Some Content</div>
{% endif %}
Thanks.
Since a product can be listed in multiple categories, you'll need to use a for
loop to go through all the categories, and then include an if
statement to check the name - like so:
{% for category in product.categories %}
{% if category.name == 'Shirts' %}
<div>Your content</div>
{% endif %}
{% endfor %}