Access collections rules / conditions object through liquid

Highlighted
New Member
3 0 1

When accessing the products object, there's the collections array where it shows all the collections where the product is in. Within each collection object, I see a rules field that has the condition(s) which the collection is using to filter the products. I can't seem to access that 'rules' field through liquid, it returns as null. Anyone with some idea why I can't / what I can do to access the conditions where the collections are using? Thanks!

Highlighted

Hi kevinyeh, could you post some screenshots? I don't see a rules attribute in the collections object. (https://help.shopify.com/en/themes/liquid/objects/collection).

 

 

Making Shopify Tasks Straight Forward. Contact me directly to get help with your Shopify website quickly and painlessly.

Website: https://theshoptinkerers.com/
0 Likes
Highlighted
Tourist
4 0 1

I´m having the same issue right now.

 

My "var dump"

{{ collection | json }}

outputs the following object:

{
   "id":174687682605,
   "handle":"black-pattern",
   "title":"Black Pattern",
   "updated_at":"2020-04-14T11:25:42+02:00",
   "body_html":"",
   "published_at":"2020-02-13T11:28:22+01:00",
   "sort_order":"best-selling",
   "template_suffix":"",
   "disjunctive":false,
   "rules":[
      {
         "column":"variant_title",
         "relation":"contains",
         "condition":"black"
      },
      {
         "column":"variant_title",
         "relation":"contains",
         "condition":"pattern"
      }
   ],
   "published_scope":"web"
}

 

I need to perform further filtering based on those rules near the end. However {{ collection.rules | json }} returns null. Everything else I can think of would be a very hacky solution at best.

Thanks for any hints.