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.
Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024In today’s interview, we sat down with @BSS-Commerce to discuss practical strategies f...
By JasonH Nov 13, 2024