Skip to main content

Hello, I created a zap to send an email to our suppliers from a Shopify order, but if there are multiple vendors in one order it sends an email with all the products to all vendors in that order. I would like to be able to split the email into multiple emails, with each vendor only getting the line item in an email that is relevant to them. Or at least not display the irrelevant items to vendors who don’t need the data for items they don't dropship as to not confuse them with more products than they need to fulfill.

This is the code that splits the line items so it is easier to read, and the previous step is a filter that reads the vendor and only continues to the email relevant to that vendor. 

If anyone has any ideas of how to send an email to each vendor with only the line item relevant to that vendor from one order please let me know! 

Thanks

-Mike

Hi @Mikemo77 

I think you could remove your filter and handle the mapping in the code step. Do you know which line item would go to which vendor? Just by filtering off sku or name? If so, you can manipulate your code step to create associations for each vendor. 

Then for your output, you would output an array of objects. Each object would relate to a different vendor. Zapier will handle it as a loop and send an email for each object returned in the array. 


Thanks for the reply! I can add an input data that pulls the line item vendor from the Shopify order data, and that would be who it needs to be sent to. I only have limited experience with writing code so I’m not quite sure how I would create an output array that would separate into different emails for each vendor. Right now I have a zap for each individual vendor with a filter before the code that only continues if “line item vendor contains” “vendor name” then sends that entire order to each vendor in that order. So one order fires multiple zaps but they all contain the same info and go to different places. 

Here is an example of another orders output with 2 items, but these 2 have the same vendor. If these were 2 different vendors how would I send one line item to one email and one email to the other?


Hi @Mikemo77 

If you’d like to hire us to write that out for you and consolidate everything into 1 zap. Feel free to shoot me a direct message. 

Otherwise, to only send and email with line items related to the vendor would just take a quick modification to your code.

Add vendors into your inputData then In your qtys.forEach(qty) loop. you will just need to add an if statement that checks to see if the vendor is the vendor of interest.

The output of which will just be the line items that had the vendor matching the if statement

 


Hey @GetUWired , 

I think I got it to work with the information you provided, I really appreciate it! If I run into any problems I’d be happy to hire you in the future. Ill let you know. 

Thanks

-Mike


Love It!

Glad you got it working!