Hide cart icon unless logged in

I’m wondering what code is needed to hide cart icon before customer is logged in?

I’m using Trade theme.

It’s a B2B site.

Thanks in advance!

  • Here is the solution for you @Solly_1
  • Please follow these steps:

  • Then find the theme.liquid file.

  • Then add the following code at the end of the file and press ‘Save’ to save it.

  • Paste the below code before on theme.liquid

{% unless customer %}

{% endunless %}
  • If it doesn’t work, please share your store link for me to check

  • Please press ‘Like’ and mark it as ‘Solution’ if you find it helpful. Thank you.

Hi @Solly_1

You can do that by following these steps

  • Please log in to your Shopify store admin
  • From Sale channels > Online Store
  • In Themes > click “…” next to Trade theme > Edit code
  • Open header.liquid file
  • Replace code from lines 289 to 306 with this code below and save file
{% if customer %}      
    
        {%- liquid
          if cart == empty
            render 'icon-cart-empty'
          else
            render 'icon-cart'
          endif
        -%}
        {{ 'templates.cart.cart' | t }}
        {%- if cart != empty -%}
          

            {%- if cart.item_count < 100 -%}
              {{ cart.item_count }}
            {%- endif -%}
            {{ 'sections.header.cart_count' | t: count: cart.item_count }}
          

        {%- endif -%}
  
{% endif %}​