Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
I'm trying to write a loop that will list the properties of an object. Not necessarily the values of the properties, just a list of the properties a particular object has.
Does anyone know how to do that?
It'd be great if there was a consistent way to iterate over an object, but as it stands the most complete information is in the Shopify liquid docs if you're looking at built in objects.
The next best option is to use the "to json" filter. For example:
<!-- Assuming you're in a product liquid template... -->
<script>console.log( {{ product | json }} );</script>
This will give you most object keys (and values). However:
Hope that helps!
Andrew.
Unfortunate for me, I am precisely looking for "inventory details on variants".
Working on a pet project, trying to see if It is somehow possible to display inventory quantities of each location. I could print all the locations where a variant is available, but the count is apparently not accessible.
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024