If array contains element in Liquid file.
For example, we want to know whether the cart contains a specific product.
First, get a product Array by split in Cart.liquid
Iterate the cart items, get variant ID in each loop. Check if the variant is the one we want.
1 | {% assign gotIt = false %} |
Or, you want to know if there’s a specific item in Checkout page.
The process is same with above codes.
Notice that you can get the variant_id from Checkout API, it’s in line_item.variant_id
1 | {% assign gotIt = false %} |
And, you may also do the check by arr contains str grammer.
原文作者: dgb8901,yinxing
原文链接: https://www.itwork.club/2021/11/19/arr-contain-ele-in-liquid/
版权声明: 转载请注明出处
为您推荐
体验小程序「简易记账」
关注公众号「特想学英语」