Shopify themes, liquid, logos, and UX
Okay, so I'm attempting to create different menus visible to customers with different tags. Specifically, I want customers tagged "Wholesale" to have a different set of navigations to any other customer.
https://chevronediting.com.au/exclude-products-from-shopify-search/
I've been using these two resources to guide me, and everything has gone correctly except for the edits in header.liquid.
I'm want to use {% unless customer.tags contains 'Wholesale' %} [regular navigation/menus] {% else %} [Wholesale menu navigation], but I can't figure out how to get the alternate menus to show up. The above links talk about code that looks like {% for link in linklists[section.settings.main_linklist].links %}, but I don't see any {% for %} tags in the header at all, instead I see {%- assign main_menu = linklists[section.settings.main_menu_link_list] -%} which I think is pulling from settings_data.json. I don't know anything about JSON, and I've sort of been faking my way through Liquid so far, so I'm sort of lost from this point.
Does anyone have any recommendations for how to get these different menus to show? I'm happy to provide more in-depth explanations or code chunks.
Solved! Go to the solution
This is an accepted solution.
{%- assign main_menu = linklists[section.settings.main_menu_link_list] -%}
This line isn't pulling from your settings_data.json file, its pulling from the header section's {% schema %} -- If you go to your customize editor and go to your header section there'll be an option on the sidebar to choose the linklist you want to use. So that's actually the line you're looking for. You'll want to do something like this:
{% unless customer.tags contains 'wholesale' %}
{%- assign main_menu = linklists[section.settings.main_menu_link_list] -%}
{% else %}
{%- assign main_menu = linklists.wholesale-menu-handle -%}
{% endunless %}
This is an accepted solution.
{%- assign main_menu = linklists[section.settings.main_menu_link_list] -%}
This line isn't pulling from your settings_data.json file, its pulling from the header section's {% schema %} -- If you go to your customize editor and go to your header section there'll be an option on the sidebar to choose the linklist you want to use. So that's actually the line you're looking for. You'll want to do something like this:
{% unless customer.tags contains 'wholesale' %}
{%- assign main_menu = linklists[section.settings.main_menu_link_list] -%}
{% else %}
{%- assign main_menu = linklists.wholesale-menu-handle -%}
{% endunless %}
I am having the same issue but don't understand the solution above...
I see this code in my header.liquid file (in sections).
{%- assign main_menu = linklists[section.settings.main_menu_link_list] -%}
And I am following a tutorial to replace it with the below code. I did create a menu called "main-menu-wholesale" and my regular main menu is called "main-menu" but I keep getting an error if I replace the above code with the below code. What am I doing wrong?
{% assign menu_handle = 'main-menu' %}
{% if customer %}
{% if customer.tags contains 'wholesale' %}
{% assign menu_handle = 'main-menu-wholesale' %}
{% endif %}
{% endif %}
{% for link in linklists[menu_handle].links %}
Are you ready to take your business to the next level? Look no further than the latest ...
By SarahF_Shopify Apr 15, 2024We’re keeping the ball rolling to make sure you’re always ahead of the game. So buckle ...
By JasonH Apr 8, 2024Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024