If 语句取决于产品所属的类别(大卡特尔)
If Statement depending on the Category a Product belongs to (Big Cartel)
我可以根据产品所属的类别在 Product.html 页面上创建 if 语句吗?像这样:
{% if product.category.name == 'Shirts' %}
<div>Some Content</div>
{% endif %}
谢谢。
由于一个产品可以在多个类别中列出,您需要使用 for
循环遍历所有类别,然后包含一个 if
语句来检查名称 -像这样:
{% for category in product.categories %}
{% if category.name == 'Shirts' %}
<div>Your content</div>
{% endif %}
{% endfor %}
我可以根据产品所属的类别在 Product.html 页面上创建 if 语句吗?像这样:
{% if product.category.name == 'Shirts' %}
<div>Some Content</div>
{% endif %}
谢谢。
由于一个产品可以在多个类别中列出,您需要使用 for
循环遍历所有类别,然后包含一个 if
语句来检查名称 -像这样:
{% for category in product.categories %}
{% if category.name == 'Shirts' %}
<div>Your content</div>
{% endif %}
{% endfor %}