Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
How do I insert an object into an array of objects?
I have a for loop that is looping through one array and I have code that is filtering it by some properties to extract the objects that I need from it, the issue is that I want these objects to also be in an array:
{% for uniqueVariant in uniqueVariants %}
{% assign uniqueFirstAvailableVariants = product.variants | where: "option1", variants[forloop.index] | where: "available", true | first %}
{% endfor %}
So how do I initialize uniqueFirstAvailableVariants as an empty array and then just insert the matching objects in it? Because right now uniqueFirstAvailableVariants is giving me just one object and it is the last object that is found that matches the conditions (and tha tis expected since its not an array)
Hey Community! As we jump into 2025, we want to give a big shout-out to all of you wh...
By JasonH Jan 7, 2025Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024