Ad

Block Cart Icon For Certain Customer Tags On Shopify

- 1 answer

I'm trying to block customers tagged with "Wholesale" from the cart icon but it seems to block everybody. I've also tried to add this tag markup but won't let me add in {% include %} without giving me some type of error.

          {% unless customer.tag contains 'Wholesale' %}
            {% include 
            <li class="site-nav__item">
              <a target="_blank" rel="nofollow noreferrer" href="/cart" class="site-nav__link site-nav__link--icon cart-link js-drawer-open-right" aria-controls="CartDrawer">
                <span class="icon-fallback-text">
                  <span class="icon icon-cart" aria-hidden="true"></span>
                  <span class="fallback-text">{{ 'layout.cart.title' | t }}</span>
                </span> 
                <span class="cart-link__bubble{% if cart.item_count > 0 %} cart-link__bubble--visible{% endif %}"></span>
              </a>
            </li> %}
           {% endunless %}
Ad

Answer

Your include usage is wrong. It is used to load only snippet files. Just remove {% include and it's corresponding %} and you're good to go.

Also it's customer.tags.

 {% unless customer.tags contains 'Wholesale' %}
  <li class="site-nav__item">
    <a target="_blank" rel="nofollow noreferrer" target="_blank" rel="nofollow noreferrer" href="/cart" class="site-nav__link site-nav__link--icon cart-link js-drawer-open-right" aria-controls="CartDrawer">
      <span class="icon-fallback-text">
        <span class="icon icon-cart" aria-hidden="true"></span>
        <span class="fallback-text">{{ 'layout.cart.title' | t }}</span>
      </span> 
      <span class="cart-link__bubble {% if cart.item_count > 0 %} cart-link__bubble--visible{% endif %}"></span>
    </a>
  </li> 
 {% endunless %}
Ad
source: stackoverflow.com
Ad