Hi, i have been strugeling with this issue also and i could not manage to use your solution. But now with “write Code” it was very easy
This was the setup
Then by addin “run Code” i could take the quantity of the spesific SKU as a variable in the “add order line”
input
{
order {
lineItems {
sku
quantity
}
}
}
Output
type Output {
totalQuantity: Int!
}
Write code
export default function main(input) {
let totalQuantity = 0;
input.order.lineItems.forEach(item => {
if (item.sku === ‘90009’) {
totalQuantity += item.quantity;
}
});
return {
totalQuantity: totalQuantity,
};
}
And here is the add order line
Worked like a charm


