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
}
}
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