Solved

Hide current product from collection

thanksagain_
Tourist
8 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
7061 1334 1356

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 or Accept solution, - Coffee Tips or Paypal Tips
- Ryviu - Product Reviews app, collect product reviews, import reviews from AliExpress, Amazon, Etsy, Shopee and Walmart and CSV.
- Lookfy app: Create Image Lookbook, Photo Gallery with product hotspots
- Enjoy 1 month of Shopify for $1. Sign up now

View solution in original post

Replies 10 (10)

PaulNewton
Shopify Partner
6274 572 1312

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.

Save time & money ,Ask Questions The Smart Way


Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com


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

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


Dan-From-Ryviu
Shopify Partner
7061 1334 1356

Hi, could you share your store link?

- Helpful? Like or Accept solution, - Coffee Tips or Paypal Tips
- Ryviu - Product Reviews app, collect product reviews, import reviews from AliExpress, Amazon, Etsy, Shopee and Walmart and CSV.
- Lookfy app: Create Image Lookbook, Photo Gallery with product hotspots
- Enjoy 1 month of Shopify for $1. Sign up now

Dan-From-Ryviu
Shopify Partner
7061 1334 1356

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 or Accept solution, - Coffee Tips or Paypal Tips
- Ryviu - Product Reviews app, collect product reviews, import reviews from AliExpress, Amazon, Etsy, Shopee and Walmart and CSV.
- Lookfy app: Create Image Lookbook, Photo Gallery with product hotspots
- Enjoy 1 month of Shopify for $1. Sign up now

thanksagain_
Tourist
8 0 1

this worked! thank you

Dan-From-Ryviu
Shopify Partner
7061 1334 1356

You are very welcome

- Helpful? Like or Accept solution, - Coffee Tips or Paypal Tips
- Ryviu - Product Reviews app, collect product reviews, import reviews from AliExpress, Amazon, Etsy, Shopee and Walmart and CSV.
- Lookfy app: Create Image Lookbook, Photo Gallery with product hotspots
- Enjoy 1 month of Shopify for $1. Sign up now

gr_trading
Shopify Partner
1608 139 173

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. | YouTube Videos
To support Buy Me a Coffee
thanksagain_
Tourist
8 0 1

thank you. will try this and get back to you

thanksagain_
Tourist
8 0 1

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

gr_trading
Shopify Partner
1608 139 173

Can you share the preview theme URL 

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