A way to redirect a tagged customer that lands on the home page.

Solved
New Member
3 0 0

Is there a way to redirect any customer that has a tag (ie. wholesale) to a specific page, only if they land on our home page?

 

I have wholesale built into our website, and when a wholesale customer logs in, they see only the wholesale menus and account info.  But they can manually still go to our main website address if logged in, and see our direct to customer pages. Im trying to avoid this by having only our main page check to see if they are tagged wholesale, and redirect them if they are.  

 

I have tired this

{% if customer.tags contains 'wholesale'%}
<script>window.location.href= 'pages/retailer-news-and-updates'</script>
  {% endif %}
on the customer/accounts.liquid page, but it only work when they sign in, or click on my account.  
 
I would like it to only work if they go to the home page (ie. theover.co) and redirect to 'pages/retailer-news-and-updates'
 
I am using Out of the Sandbox Parallax theme
 
Thanks for any help
0 Likes
Highlighted
Shopify Expert
2506 423 532

Hi @TheOVerCompany 

You can use this condition in Theme.liquid file

{% if customer && template contains 'index' && customer.tags contains 'wholesale'%}
    <script>window.location.href= 'pages/retailer-news-and-updates'</script>
{% endif %}

So if user on home page + logged in + wholesale customer tagged  then its redirect to page.

Want to modify or custom changes on store hire me.
If helpful then please Like and Accept Solution.
Email: jasoliyabrijesh123@gmail.com
Skype: jasoliya.brijesh
Want to get Free review and advice for sale on store ?? just text me here
0 Likes
New Member
3 0 0

Hello Jasoliya,

 

Thank you for this, I tried it out but it created a loop that didn't go anywhere.  Here is a screen cap of what was happening.  If this works it will be amazing.

0 Likes

Success.

Shopify Expert
2676 65 668

The code is a bit off, it should have  and  instead of && and have a slash at the beginning of the url

{% if customer and template contains 'index' and customer.tags contains 'wholesale'%}
    <script>window.location.href= '/pages/retailer-news-and-updates'</script>
{% endif %}

Plus you can put it into index.liquid template -- this way the code will run only on the home page anyway

Want to hire me to tweak a theme? Mail me at tairli@yahoo.com!
My post solved your problem? Like it!
1 Like
New Member
3 0 0

Thank you Tim,  This worked perfect!  

0 Likes