On Shopify, check if a given product is not on any collection

user1528465

Within the product page, I would like to hide a certain element if the current product isn't associated with any collection. Is there any way to check it with Liquid ?

Alice Girard

The object product.collections is an array containing all collections where the product is listed.

So you may use this:

{% if product.collections.size < 1 %}
    Do something
{% endif %}

Documentation about arrays here: https://shopify.dev/api/liquid/filters#size

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to get the URL for any product in Shopify Shop given that its pattern varies if it belongs to a collection?

Shopify - Template check within product-loop

Shopify theme how to check product description text

Displaying the current collection on a product info page (shopify liquid)

Shopify, displaying price of first in stock product variant on Collection page

Shopify: Remove product from collection via API call

How to determine if a product is part of a hidden collection in Shopify liquid templates?

How to add "you added this" bellow the product in the collection SHOPIFY

Shopify - Add Number (1,2,3) before Product in Collection

How do i check product page template in shopify

Woocommerce: function to check if the cart contains any product

How can I add a check to see if a collection on Shopify is available / published?

Check if Collection of DTOs sorted by a given field

Check a collection of SIDs for membership in a given group

Shopify send product with options on shopify

How to check if a value is present in any of given sets

TypeScript - Check if given 'any' parameter is custom type?

Check if any (all) character of a string is in a given range

To check if there are any a and b that satisfy the given equation

Python: Check if any file exists in a given directory

VBA to check if any cell is not blank in given range

check whether string contains any of the given charsequence

How to check if a given string is a part of any given Enum in Java?

Check if any key exist from given multiple keys in a given dictionary

Shopify - How can I match the display order of tags to product display order in a collection?

how to check if any of given queries return any result in knex

Is there any way to check if a given string exists in any array element?

How to bundle product in shopify?

Shopify - Free Product with Purchase