当集合未发布/可用时,如何纠正“液体错误:比较字符串与0失败”?
如果我使该收藏集不可用/未发布,我有 “液体错误:字符串与0的比较失败” 在前端。
移除
{% if collections['catalogue'].products_count > 0 %}
显示“即将推出”
我认为这是有问题的生产线,但我需要检查是否有产品。
我也尝试添加
{% if collections['catalogue'] %}
我需要完全隐藏目录部分,直到可用为止
{% if collections['catalogue'].products_count > 0 %}
<div class="contain collection collection--home" data-intro="fade-in-up">
<header role="banner" class="collection__title">
<h1 class="h3 font--condensed text--upper">Catalogues</h1>
</header>
<div class="collection-grid">
{% for product in collections['catalogue'].products limit:1 %}
{% include 'collection-item' %}
{% else %}
<p>{{ 'collections.general.no_matches' | t }}</p>
{% endfor %}
</div>
</div>
{% endif %}
对不起,我是液体,Shopify nooob:-/
答案 0 :(得分:1)
您可以检查发布日期,因为发布日期是null
(未发布时)。
{% if collections['catalogue'].published_at != empty %}
// your code
{%- endif -%}
请记住,您正在检查代码中的产品数量,但是您要求的是2种不同的货品。某个收藏集可能不可用,但仍然有商品。
如果要检查产品,请将其替换为:
{% if collections['catalogue'].products.size > 0 %}
// your code
{%- endif -%}