Shopify themes, liquid, logos, and UX
Hi, I am trying to hide certain products from the search function on my website. I have added a tag on all of these items, '_HIDDEN_PRODUCT', and am trying to edit the search.json file to not include product with this tag.
I have tried changing the if statement to {%- if result.object_type == 'product' && result.tags !contains '_HIDDEN_PRODUCT' -%}, which doesn't seem to work.
I have also tried other solutions such as surrounding it in if statements:
{%- if result.tags contains '_HIDDEN_PRODUCT' %-}
{%- assign display = false %-}
{%- endif %-}
{%- if display == true %-}
and I have also tried the same implementation but iterating through the tags
{%- for tag in result.tags %-}
{%- if tag contains '_HIDDEN_PRODUCT' %-}
etc.
Can anyone offer any advice on this? It would be much appreciated
Thanks.
Please use unless logically simple so you shouldn't have issues due to logic
{% if item.object_type == 'product' %}
{% assign product = item %}
{% unless product.tags contains '_HIDDEN_PRODUCT' %}
{% include 'product-grid-item' %}
{% endunless %}
{% else %}
// Usual code
{% endif %}
Hi!
I'm having a similar issue, just wondering where would you place this code? I'm using the Venture template.
Thank you!
I've developed this app that does the job without modifying your theme code: https://apps.shopify.com/hide-from-search - check it out.
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024