Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
On an order i want to count the ordered quantity of a specific product by SKU.
I tried doing it with Sum of order.lineitems.Quantity. however in this case, its just counting the total quantity of all products which i dont want. Is there any function that can do this ? i've looked around quite a bit but didn't find anything in the app
Solved! Go to the solution
This is an accepted solution.
thanks for the input, i managed to get the correct values using custom code that looks like this :
export default function main(input) {
let Quantity = 0;
input.order.lineItems.forEach((item) => {
if (item.sku === "XX") {
Quantity += item.quantity;
}
});
return {
Quantity: Quantity,
};
}
Summing that variable would just give you the total number products ordered.
It's not clear how you need that quantity (for a condition or in an action). But you need to check if the line item has that sku. The quantity field you found already tells you how many of that lineItem is in the order.
This is an accepted solution.
thanks for the input, i managed to get the correct values using custom code that looks like this :
export default function main(input) {
let Quantity = 0;
input.order.lineItems.forEach((item) => {
if (item.sku === "XX") {
Quantity += item.quantity;
}
});
return {
Quantity: Quantity,
};
}
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