Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
I tried doing it with Sum of order.lineitems.Quantity. However, its just counting the total quantity of all products in an order which I dont want.
Is there any function that can do this? like either using tag, URL or anything that will help me implement this easily
I've looked around quite a bit but didn't find anything in the app. Please help. Newbie here - may need some steps.
I believe you can't do this directly with Flow builder.
You'd need to use Liquid to do it.
Not sure what Action you want to perform with this count, but in the "Value" entry field you can enter Liquid similar to this:
{%- liquid
assign count = 0
for li in order.line_items
if li.product.handle == "handle-of-special-product"
assign count = count | plus: li.quantity
endif
endfor
-%}
In this order there is {{ count }} of our special product.
Hello Tim,
Thank you for the response. Im not sure if this helps clarify things but the logic Im trying to build is:
🤞Hope there's a way to do this..
You can use “Run code” action to calculate the number of items in an order:
Input:
query{
order{
lineItems{
sku
quantity
}
}
}
Output:
type Output {
"The total number of items returned by this buyer"
totalQuantyty: Int!
}
Code:
export default function main(input) {
let totalQuantyty = 0;
input.order.lineItems.forEach(lineItem => {
if (lineItem.sku === 'SOME_SKU') {
totalQuantyty += lineItem.quantity;
}
});
return {
totalQuantyty,
}
}
Then, you can use the resulting value in the “Send Admin API request” action.
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025