Shopify themes, liquid, logos, and UX
Hello,
I am not an expert in liquid but I just did some research on the forum to find how I could hide products with a certain tag in a collection usiing liquid . I came across this thread. : https://ecommerce.shopify.com/c/ecommerce-design/t/hide-products-from-all-products-but-still-have-th...
I used the same code provided as solution number two in response to this thread and changed it my way .:
{% for product in collection.products %}
{% assign displayProduct = true %}
{% if product.tags contains 'outlet' %}
{% assign displayProduct = false %}
{% endif %}
{% if displayProduct == false %}
{% endif %}
{% endfor %}
The goal here is to hide products which are tagged "outlet" so they do not show up in "all" collection.
But I am stuck here what to I need to add after {% if displayProduct === false %} to hide the targeted products ??
Please someone help me on this one . I think I'm almost there just need a hand:;)
Thank you
Why not make an all collection with a curated list of products you want to be seen? If you do that, this will replace the default all collection that shows everything.
Thank you Jason but that is not the solution I am looking for . I already have an all smart collection filtered by price. Smart collections allow to "show products with tags " but don't allow to "exclude products with tags". The other way around of course would be to make a smart collection tagged "all" and not outlet..;;but..
..What I want is to do is leave "outlet" products visible in my shop but I don't want them to show up in the "all " collection. Now my template shows all the tags to the customers and that helps them narrow their search. For this reason I can't create irrelevant tags : tagging "all" wouldn't work because there is already an automatic all tag ( showing all products); " tagging new or else doesn't look good on the screen either and it means having to un-tag when I want to make them outlets (there could be hundreds of them!).
For me the simplest way would be to change the liquid code over smart collections (which is not such a bad idea depending on the problem).
Hi Joiakim. I see you have already solved this issue by filtering out products via liquid so I guess this response is intended for others who end up here with a similar issue and do not want to mess around with the theme.
One way Jason's suggestion can work is if you are able to use product type for this. For example, you can set product type to "Outlet" for all products that are not supposed to display on ../collections/all page. The obvious downside of this approach: you can't have more than one product type per each product so this won't work if you rely on product types for other purposes.
This is our version of this issue and what we did to solve it:
On one site we have a few add-on products which do not belong to any collections and customers should only view them inside cart. But ..collections/all page was still featuring these products. So we took the following steps:
1. Give product type "Add-on" to all such products
2. Create a new collection named Products. We use name "Products" for collection, not "All". This allows the page to look the same as default the default ../collections/all page in many themes, with "Products" as page title and main heading.
3. Choose automated collection type, and set the condition to show only products that are not of type Add-on
4. Set following values in SEO settings at the bottom:
Using Liquid will mean that your collection will have gaps in the product grid. For example if you show 50 items per page it would be possible to see 0 items if all 50 had the tag. You'll 100% end up seeing a mix of numbers that might be very weird for the customer to see.
The concept would be:
{% for product in collection.products %}
{% if product.tags contains 'outlet' %}{% continue %}{% endif %}
<!-- your product grid item -->
{% endfor %}
Hello!
How can I do the same but forcing them to login?
I mean I have certain products with a specific tag that I just want to show to people that login , I tried this in theme but it does not work
{% if product.tags contains 'password' %}
{% if template contains 'customers' %}
{% assign send_to_login = true %}
{% endif %}
{% endif %}
Thank you Jason . I will try this solution but if the result is not so appealing I guess I will stick to using smart collections.
Cheers
Hello here is my feedback after implementing the code Jason posted above , it finally worked!!!!! . I figured out I had to implement it in the "collection.liquid" file in the snippet and not the template folder. However, the products tagged outlet don't appear and no ugly gap in my product listing , as I was afraid there would be.
see the result here : https://njfootwear.com/collections/all
So thank you very much Jason, you were big help shout out.
Hey,
I know one app that can help you with the problem you are facing. AutoHide Soldout Products (https://apps.shopify.com/autohide-soldout-products) can help you with the customization that you need. They did the same for one of the clients. Download the app & contact their support team. They are really fast at responding!
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024