Shopify themes, liquid, logos, and UX
My theme is Dawn.
I am trying to hide this multicolumn section on my product page when the customer tag is "wholesale"
Thanks for any help!
Solved! Go to the solution
This is an accepted solution.
Hello, @littleroots1
1) Open the relevant Liquid file for your product page. This could be something like product-template.liquid or a section file included in it
2) Add the following Liquid code to check for the "wholesale" tag:
{% if customer %}
{% assign is_wholesale = false %}
{% for tag in customer.tags %}
{% if tag == "wholesale" %}
{% assign is_wholesale = true %}
{% endif %}
{% endfor %}
{% endif %}
<div class="multi-column-section {% if is_wholesale %}hidden-section{% endif %}">
<!-- Your multi-column content here -->
</div>
And in your CSS file:
.hidden-section { display: none; }
This setup will check if the logged-in customer has the "wholesale" tag
Hi @littleroots1
You can check if the customer is logged in and if the customer contains the tag like below code👇
{% if customer %}
{% unless customer.tags contains 'wholesale' %}
// Add your multicolumn HTML / Liquid code
{% endunless %}
{% endif %}
Thank you
D.P
This is an accepted solution.
Hello, @littleroots1
1) Open the relevant Liquid file for your product page. This could be something like product-template.liquid or a section file included in it
2) Add the following Liquid code to check for the "wholesale" tag:
{% if customer %}
{% assign is_wholesale = false %}
{% for tag in customer.tags %}
{% if tag == "wholesale" %}
{% assign is_wholesale = true %}
{% endif %}
{% endfor %}
{% endif %}
<div class="multi-column-section {% if is_wholesale %}hidden-section{% endif %}">
<!-- Your multi-column content here -->
</div>
And in your CSS file:
.hidden-section { display: none; }
This setup will check if the logged-in customer has the "wholesale" tag
Hi @littleroots1 ,
This is Polo from MS Web Designer.
I would love to assist you with your query. Here is the solution:
Add this custom css class on this sections main div class=”hide-wholesale” then you have to add this sort code on product.liquid file
{% if customer %}
{% unless customer.tags contains 'wholesale' %}
.hide-wholesale{
Display: block;
}
{% endunless %}
{% else %}
.hide-wholesale{
Display: none;
}
{% endif %}
If you have any doubt, please feel free to ask.
Regards
Polo
If it’s helpful to you, please mark it as a solution.
Need Help with Shopify Speed Optimization and Any Custom Shopify tasks
email: [email protected]
Download Free Shopify Speed Optimization Guide book for 2024
Hi @littleroots1 ,
May I suggest to update code these steps:
1. Go to Store Online-> theme -> edit code
2. sections/multicolumn.liquid
3. Add code below to top of file
{% assign showContent = true %}
{% if request.page_type == 'product' and customer.tags contains 'wholesale' %}
{% assign showContent = false %}
{% endif %}
{% if showContent %}
4. Add code below to before "{% schema %}" code
{% endif %}
Hi @littleroots1 ,
To hide a multicolumn section on your product page when the customer tag is "wholesale," you can use Liquid to conditionally render the content based on the customer's tag.
Here’s how you can do it
1. In your Shopify admin, navigate to "Online Store" under Sales Channels. Click the three dots next to the theme you wish to edit, then select "Edit Code". Refer to the screenshot for guidance.
2. Locate or search the `multi-column.liquid` file in the 'Sections' folder.
3. Add the following code after {%- endstyle -%} tag. (refer screenshot)
{% unless customer.tags contains 'wholesale' %}
4. Add the following code before {% schema %} tag.(refer screenshot)
{% endunless %}
If you need further assistance, feel free to reach out!
I hope this helps! If it does, please like it and mark it as a solution!
Regards,
Sweans
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024