Re: Hide sections on product page based on customer tag - Dawn theme

Solved

Hide sections on product page based on customer tag - Dawn theme

littleroots1
Tourist
4 1 0

My theme is Dawn.

 

I am trying to hide this multicolumn section on my product page when the customer tag is "wholesale"

Screen Shot 2024-07-16 at 11.05.39 PM.png

 

Thanks for any help!

Accepted Solution (1)

oscprofessional
Shopify Partner
16115 2409 3123

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

Get pass your Store Core Web Vital Free Speed Optimization Audit, Chat on WhatsApp | Skype : oscprofessionals-87 | Email: [email protected] | Hire us | Guaranteed Site Speed Optimization | Website Free Audit | Shopify Theme Customization | Build Shopify Private App | Shopify SEO | Digital Marketing | Oscp Upsell & Cross sell App : Free | Oscp Sales & Volume Discount App : Free | Custom Pricing Wholesale App : Free

View solution in original post

Replies 5 (5)

Huptech-Web
Shopify Partner
930 187 196

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

 

If you found this response helpful, please do like and accept the solution. Thanks!
Need support with Customizing your Shopify store?
Feel free to contact me at [email protected] or Visit our website Huptech Web.
Instant Shortcode Builder: Integrate customizable UI features anywhere in your store - No coding knowledge required

oscprofessional
Shopify Partner
16115 2409 3123

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

Get pass your Store Core Web Vital Free Speed Optimization Audit, Chat on WhatsApp | Skype : oscprofessionals-87 | Email: [email protected] | Hire us | Guaranteed Site Speed Optimization | Website Free Audit | Shopify Theme Customization | Build Shopify Private App | Shopify SEO | Digital Marketing | Oscp Upsell & Cross sell App : Free | Oscp Sales & Volume Discount App : Free | Custom Pricing Wholesale App : Free

polo_msweb
Shopify Partner
18 1 4

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 

EBOOST
Shopify Partner
1196 310 351

Hi @littleroots1 ,

May I suggest to update code these steps:

1. Go to Store Online-> theme -> edit code

EBOOST_1-1672356985580.png

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 %}

 

 

EBOOST_2-1721201067818.png

 

 

4. Add code below to before "{% schema %}" code

 

 

{%  endif %}

 

 

EBOOST_3-1721201105170.png

 

 

- Hope can help. If you find my reply helpful, please hit Like and Mark as Solution
- Need a Shopify developer? Contact email: [email protected]
- Visit our site: https://www.eboosttech.net to view and download shopify themes and magento2 extensions free
- ❤❤DONATE ❤❤Coffee tips

Sweans
Shopify Partner
406 79 123

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.

Sweans_0-1721206241855.png

 

 

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' %}

 

Sweans_0-1721206364796.png

 

 

 

4. Add the following code before {% schema %} tag.(refer screenshot)

 

{% endunless %}

 

Sweans_1-1721206440922.png

 

 

 

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

- Was my reply helpful? Please Like and Accept the Solution or let me know by Buying me coffee!
- Want to modify or custom changes on store Hire me.
- Feel free to contact me at [email protected] regarding any help.
- To know more about me check out www.sweans.com