【问题标题】:Hiding empty cart in Shopify在 Shopify 中隐藏空购物车
【发布时间】:2017-10-26 14:18:48
【问题描述】:

我试图在购物车为空时隐藏我的购物车,并在 header.liquid 文件中找到了我的购物车代码 sn-p

<a href="/cart" class="site-header__cart">
{% include 'icon-cart' %}
<span class="visually-hidden">{{ 'layout.cart.title' | t }}</span>
<span class="icon__fallback-text">{{ 'layout.cart.title' | t }}</span>
{% if cart.item_count > 0 %}
<div id="CartCount" class="site-header__cart-count">
<span>{{ cart.item_count }}</span>
<span class="icon__fallback-text medium-up--hide">{{ 'layout.cart.items_count' | t: count: cart.item_count }}</span>
</div>
{% endif %}
</a>

我也尝试过使用我在此处找到的代码 (https://ecommerce.shopify.com/c/ecommerce-design/t/hide-cart-checkout-button-when-cart-is-empty-115075)

{% if cart.item_count != 0 %}

这两个都不适合我,有什么建议吗?

【问题讨论】:

    标签: shopify hidden cart


    【解决方案1】:

    您可以使用此代码,如果这有助于您解决问题,请告诉我们:

    {% if cart.item_count > 0 %} your html here {% endif %}
    

    如果您的主题使用 ajax 添加到购物车功能,如果您的页面在添加到购物车期间未刷新,您还需要对 js 进行一些更改。

    谢谢

    【讨论】:

    猜你喜欢
    • 2020-06-06
    • 1970-01-01
    • 1970-01-01
    • 2015-08-29
    • 1970-01-01
    • 1970-01-01
    • 2022-06-10
    • 2016-11-18
    • 1970-01-01
    相关资源
    最近更新 更多