Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
Trying to create a flow that will add a total the lineitem price in an order for all lineItems that have a product with a specific Tag.
In particular, we have a few different items in our store that are donations (membership, specific campaigns, and just donating). I need to total all the line items that are of type donation, so that we can send an email for tax deduction purposes.
I thought I was onto something with the flow attached, but for the value, I couldn't figure out how to reference the line item the flow is iterating through.
You're going to probably need a little run code step for this.
Thanks Kalen, you were correct. The flow I was using didn't seem to return the Sum to the proper place in the flow.
In case future people need the solution, I was able to get it to work with the following:
Run Code
query{
order{
id,
lineItems {
product {
tags
},
discountedTotalSet{
shopMoney {
amount
}
}
}
}
}
type Output {
totalDonation: Float!
}
export default function main(input) {
const tagToMatch = "Donation";
const totalDonation = input.order.lineItems.reduce((total, item) => {
if (item.product.tags.includes(tagToMatch)) {
return total + item.discountedTotalSet.shopMoney.amount;
}
return total;
}, 0);
return {
totalDonation
}
}
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