Calculate sum of metafield for all line items using Shopify Flow

Calculate sum of metafield for all line items using Shopify Flow

monnedepraetere
Tourist
9 0 1

We want to use Shopify Flow to decide which shipping box size is needed for a specific order. We would add to each of our physical products a metafield 'size score' where we store the size score each product*. For each order we then want to sum up the total size score and based on this, decide which shipping box should be used for the order. We would then add the right shipping box as a line item to the order.

 

The main question here now is: how can we calculate in Shopify Flow the total of all the 'size scores' accross all line items for an order? I currently don't see a way of accessing the metafield data per line item, but perhaps I am missing something?

 

Any help is greatly appreciated!

 

* We only have a limited number of product sizes & a size score of 1 reflects the size of our most common packaging size. All sizes are therefore scaled to this most common product. We only have three shipping box sizes, meaning we don't need very complex algorithms or apps like Boxify to make this work.   

Reply 1 (1)

Kalen_Jordan
Shopify Partner
737 34 128

You might be able to loop over line items and then retreive a metafield value for the associated product_id or variant_id. I think you can only do one step under a for loop though - but then I think you might be able to pass all of that into a code step to sum them up.