Conditionally displayed elements on my website that show based on customer tag not updating?

Conditionally displayed elements on my website that show based on customer tag not updating?

brendaanne3
Shopify Partner
39 0 16

I have a theme that shows a different logo when a specific customer segment is logged in with specific tags. It shows fine and everything works, then I published a new version of my theme. Everything is still in there with the liquid tags for displayed a different image when the customer has a specific tag, but it stops displaying in my browser for those customers unless they manually clear their cache or open the site and log in via a private/incognito browser window. I don't want this happening everytime I push a new theme edit live.

Why is this happening and how can it be avoided?

 

During sale periods, I duplicate my existing theme with all the correct code and update a few images here and there so I can sechdule that duplicate to go live for the sale but when it's pushed live - even though all the same coding is in tact for this functionality - it stops working. For context, I'm using the Sleek theme.

This is the custom code snippet to show a different logo based on customer tag:

        {% if customer and customer.tags contains 'CUSTOM-catalog' %}
          <img
          src="custom-catalog-logo.png"
          loading="eager"
          width="{{ logo_mobile.width }}"
          height="{{ logo_mobile.height }}"
          alt="{{ logo_mobile.alt | default: shop.name | escape }}"
          class="logo header__logo--mobile md:hidden"
          style="max-width:250%!important;margin-left:-50px;"
        >
        {% else %}
        <img
          srcset="{{ logo_mobile | image_url: width: logo_width_mobile }} 1x, {{ logo_mobile | image_url: width: logo_width_mobile_2x }} 2x"
          src="{{ logo_mobile | image_url: width: logo_width_mobile }}"
          loading="eager"
          width="{{ logo_mobile.width }}"
          height="{{ logo_mobile.height }}"
          alt="{{ logo_mobile.alt | default: shop.name | escape }}"
          class="logo header__logo--mobile md:hidden"
        >
        {%- endif -%}
Reply 1 (1)

Small_Task_Help
Shopify Partner
1120 53 111

Hi,

Hope this will work

- Add a Cache-Busting Trick to Logo URL

Code example (Update your src="custom-catalog-logo.png")

{% if customer and customer.tags contains 'CUSTOM-catalog' %}
  <img
    src="custom-catalog-logo.png?v={{ 'now' | date: '%s' }}"
    loading="eager"
    width="{{ logo_mobile.width }}"
    height="{{ logo_mobile.height }}"
    alt="{{ logo_mobile.alt | default: shop.name | escape }}"
    class="logo header__logo--mobile md:hidden"
    style="max-width:250%!important;margin-left:-50px;"
  >
{% else %}
  <img
    srcset="{{ logo_mobile | image_url: width: logo_width_mobile }} 1x, {{ logo_mobile | image_url: width: logo_width_mobile_2x }} 2x"
    src="{{ logo_mobile | image_url: width: logo_width_mobile }}"
    loading="eager"
    width="{{ logo_mobile.width }}"
    height="{{ logo_mobile.height }}"
    alt="{{ logo_mobile.alt | default: shop.name | escape }}"
    class="logo header__logo--mobile md:hidden"
  >
{% endif %}

Or Use Shopify’s Built-In Image Filters for Dynamic URLs

Or Disable Cache for Authenticated Customers (Advanced)

To Get Shopify Experts Help, Click Here or E-mail - hi@ecommercesmalltask.com
About Us - We are Shopify Expert India
At Google My Business - Ecommerce Small Task - Hire Shopify Developers Ahmedabad