Have your say in Community Polls: What was/is your greatest motivation to start your own business?

Re: Hide current product from collection

Solved

How can I exclude a specific product from an automated collection?

thanksagain_
Tourist
17 0 1

Hello,

I have 3 tshirts A, B, C. I have created an automation collection and all 3 tshirts have the tag "t-shirt"

 

My automated collection pulls in all tshirts with the tag and has been added as a "featured collection" section on each product page.


When viewing the product page for tshirt (A), how do I exlcude it from the collection so that I only see tshirt B & C?

Does anyone know the code to edit to obtain this result?

Accepted Solution (1)
Dan-From-Ryviu
Shopify Partner
10261 2039 2110

This is an accepted solution.

Go to your Online store > Themes > Edit code > open card-product.liquid file, find this line of code 

{%- if card_product and card_product != empty -%}

Add this code before 

{% unless card_product.id == product.id %}
<style>
  .collection .grid__item { display: none; }
  .collection .grid__item:has(.card-wrapper) { display: list-item; }
</style>

Screenshot 2023-12-27 at 11.21.50.png

And then go to the very bottom of the file, add this code at the bottom

{% endunless %}

Screenshot 2023-12-27 at 11.22.36.png

 

- Helpful? Like and Accept solution! Or Support me: Buy Coffees
- Reton: Loyalty & Rewards - Earn points through tasks, redeem for discounts, and enjoy exclusive VIP rewards!
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image: Easy and fast to create Photo Gallery, Lookbook, Shop The Look.
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- Enjoy 1 month of Shopify for $1. Sign up now.

View solution in original post

Replies 10 (10)

PaulNewton
Shopify Partner
7450 657 1565

Varies wildly by theme, always communicate in concrete terms.

Theme names, reference urls,etc

https://community.shopify.com/c/blog/how-to-get-support-from-the-community/ba-p/2254458

 

Roughly f the section is javascript based, you would need to find the featured collections product forloop

then use some liquid logic similar to the following though the variable names may be different.

{% if current_product.handle == product.handle %} {% continue %} {% endif %}

 

Good Hunting.

 

If you need this customization done for you then contact me by email for services.
Contact info in forum signature.
ALWAYS please provide context, examples: store url, theme name, post url(s) , or any further detail in ALL correspondence.

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org


Dan-From-Ryviu
Shopify Partner
10261 2039 2110

Hi, could you share your store link?

- Helpful? Like and Accept solution! Or Support me: Buy Coffees
- Reton: Loyalty & Rewards - Earn points through tasks, redeem for discounts, and enjoy exclusive VIP rewards!
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image: Easy and fast to create Photo Gallery, Lookbook, Shop The Look.
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- Enjoy 1 month of Shopify for $1. Sign up now.

Dan-From-Ryviu
Shopify Partner
10261 2039 2110

This is an accepted solution.

Go to your Online store > Themes > Edit code > open card-product.liquid file, find this line of code 

{%- if card_product and card_product != empty -%}

Add this code before 

{% unless card_product.id == product.id %}
<style>
  .collection .grid__item { display: none; }
  .collection .grid__item:has(.card-wrapper) { display: list-item; }
</style>

Screenshot 2023-12-27 at 11.21.50.png

And then go to the very bottom of the file, add this code at the bottom

{% endunless %}

Screenshot 2023-12-27 at 11.22.36.png

 

- Helpful? Like and Accept solution! Or Support me: Buy Coffees
- Reton: Loyalty & Rewards - Earn points through tasks, redeem for discounts, and enjoy exclusive VIP rewards!
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image: Easy and fast to create Photo Gallery, Lookbook, Shop The Look.
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- Enjoy 1 month of Shopify for $1. Sign up now.

thanksagain_
Tourist
17 0 1

this worked! thank you

Dan-From-Ryviu
Shopify Partner
10261 2039 2110

You are very welcome

- Helpful? Like and Accept solution! Or Support me: Buy Coffees
- Reton: Loyalty & Rewards - Earn points through tasks, redeem for discounts, and enjoy exclusive VIP rewards!
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image: Easy and fast to create Photo Gallery, Lookbook, Shop The Look.
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- Enjoy 1 month of Shopify for $1. Sign up now.

gr_trading
Shopify Partner
1969 145 204

hi @thanksagain_ 

 

Add an additional "class" to "LI" of the featured collection liquid file, please refer to the below screenshot.

 

gr_trading_0-1703695249129.png

 

Write the below CSS in main-product.liquid file 

<style>
  ._featered-{{ product.id }}{display:none}
</style>

 

Please refer to the below screenshot for reference.

 

gr_trading_1-1703695364500.png

 

 

Hope this will help....

For any custom development WhatsApp or connect at Email ID: gr.trading15@gmail.com for quick consultation. | Shopify Free codes
To support Buy Me a Coffee
thanksagain_
Tourist
17 0 1

thank you. will try this and get back to you

thanksagain_
Tourist
17 0 1

this did not work. it aligns the collection vertically and doesnt remove the featured product

gr_trading
Shopify Partner
1969 145 204

Can you share the preview theme URL 

For any custom development WhatsApp or connect at Email ID: gr.trading15@gmail.com for quick consultation. | Shopify Free codes
To support Buy Me a Coffee