Solved

Show Content To Different Customer Segments Based On Tags

MillerBuffalo
Visitor
3 0 1

Long-time lurker, first-time poster.

 

We have three Rewards tiers. All customers who create an account enter the first tier, but their Shopify profiles are not tagged. Once they reach 500 points, they enter the Badass tier and their Shopify profile is tagged with 'swell_vip_badass'. Once they reach 1000 points, they enter the Boss tier and their Shopify profile is tagged with 'swell_vip_boss'. 

 

Each tier receives different Birthday rewards points based on their tier. Each of these Birthday rewards require their own unique widget, so I'd like to display only the appropriate widget on the customer's Account page; i.e., the customer tagged with 'swell_vip_boss' only sees the 'swell_vip_boss' widget.

 

It's working correctly for the two tagged customer segments - 'swell_vip_boss' and 'swell_vip_badass' - but the third is proving to be tricky, because this segment is not tagged. This is what I've done:

 

{% if customer.tags contains 'swell_vip_boss' %}
<div class="yotpo-widget-instance" data-yotpo-instance-id="124763"></div>
{% endif %}
{% if customer.tags contains 'swell_vip_badass' %}
<div class="yotpo-widget-instance" data-yotpo-instance-id="124761"></div>
{% endif %}
{% unless customer.tags contains 'swell_vip_boss' or 'swell_vip_badass' %}
<div class="yotpo-widget-instance" data-yotpo-instance-id="124696"></div>
{% endunless %}

 

The {% unless} portion is not showing when I've added multiple tags. Should I be using a different script?

 

Thanks!

 

Accepted Solution (1)

JoesIdeas
Shopify Expert
2228 203 593

This is an accepted solution.

For multiple conditions you have to compare both, like this:

 

{% unless customer.tags contains 'swell_vip_boss' or customer.tags contains 'swell_vip_badass' %}
<div class="yotpo-widget-instance" data-yotpo-instance-id="124696"></div>
{% endunless %}

 

By the way, fun tier names, I always like seeing something different than bronze / silver / gold 😃

• Creator of Order Automator (automate tagging, fulfillment, Amazon, notifications + more)
• Shopify developer for 10+ years, store owner for 7 years
• I also make guides like Shopify Automation Tips and How to Deal with Fraud / Chargebacks

View solution in original post

Replies 3 (3)

JoesIdeas
Shopify Expert
2228 203 593

This is an accepted solution.

For multiple conditions you have to compare both, like this:

 

{% unless customer.tags contains 'swell_vip_boss' or customer.tags contains 'swell_vip_badass' %}
<div class="yotpo-widget-instance" data-yotpo-instance-id="124696"></div>
{% endunless %}

 

By the way, fun tier names, I always like seeing something different than bronze / silver / gold 😃

• Creator of Order Automator (automate tagging, fulfillment, Amazon, notifications + more)
• Shopify developer for 10+ years, store owner for 7 years
• I also make guides like Shopify Automation Tips and How to Deal with Fraud / Chargebacks

emergencyoxygen
Visitor
1 0 0

Hi there!

Nice explanation!

Is there a way to do this into the product content text area (the field called description)?
I need to hide some information to a certain group of users.


I tried your solution but the code would show up on the front end.

Screen Shot 2024-02-27 at 20.44.48.png

JoesIdeas
Shopify Expert
2228 203 593

Ya you should be able to, check the Liquid reference docs to find variable options: https://shopify.dev/docs/api/liquid/objects/product

 

product.description should work.

 

If your code is showing up on the front end, you have a syntax error or broken code somewhere.

• Creator of Order Automator (automate tagging, fulfillment, Amazon, notifications + more)
• Shopify developer for 10+ years, store owner for 7 years
• I also make guides like Shopify Automation Tips and How to Deal with Fraud / Chargebacks