How to check if Product ID is in Collection ID on Shopify storefront

block2kz
Shopify Partner
1 0 0

I'm building app that display badge on product image, my app allow user choose which product collections they want to display badge, when save to database, I save array of collection id to database. On store front, on product listing page, I want to check if product is in collection that user choose, then display badge on product image.

 

On storefront, I'm using Javascript to get all Product ID on product listing page. Now I'm struggling with how to check if each Product ID is in array of collection ID that user choose.

 

I need some recommend keywords or ideas to solve this problem. Thanks in advance.

Replies 0 (0)