Can I set a different announcement bar for logged in customers?

andra0412
Tourist
13 0 0

Hi I would like to set a different announcement bar once the customer logged in. is this possible?

Replies 3 (3)

jazz-jay
Shopify Expert
96 14 18

Hi,

 

Of course it's possible, in liquid code, check if the customer is logged in and then write some more codes to change the announcement bar. Easy.

banned
andra0412
Tourist
13 0 0

Hi! Can you help me with some code to achieve this? thank you 

webwondersco
Shopify Partner
1036 157 154

@andra0412 , Hope you are doing well.

 

Yes, this is possible. YOu can check by adding some conditions to check if the customer is logged in or not and display the content based on that.  please refer to the below code for a better understanding.

 

{% if customer %}
  {# Customer is logged in #}
  <div class="announcement-bar">
    <p>Welcome back, {{ customer.first_name }}!</p>
    {# Add your custom content for logged-in customers here #}
  </div>
{% else %}
  <div class="announcement-bar">
    <p>New to our store? Sign up now to get exclusive offers!</p>
  </div>
{% endif %}
Web Wonders | Shopify Partner | Connect here!
- Question answered? Mark as Accepted Solution, reply helpful? Click Like
- Hire me, if you want to design, re-design, develop a store, or make changes to the pre-built store.
a small Coffee Tip would be greatly appreciated. 🙂