Skip to main content
Best answer

I get the incorrect format when importing less or more than 3 line items in a Shopify order

  • Nov 25, 2022 10:22 PM UTC
  • 5 replies
  • 175 views

Forum|alt.badge.img

Hi there, hoping someone can help me with this formatting issue in zapier. I am automatically importing orders in from Shopify into google sheets. The default is for them to import like this: “Item 1, Item 2, Item 3”. My initial goal was to get them to import like this all in the same cell:

 

Item 1

Item 2

Item 3

 

I successfully did this with the line-item to text utility. See solution below:

 

So all good it seemed, until there are less or more than 3 items in an order. When there are more than 3 items, it only imports the first 3, and when there are less than 3 items, it imports to google sheets like this:

Any solutions? Thanks so much in advance.

Best answer by Todd Harper

Hi @Eric Caldwell!

Welcome to the Zapier Community!

I’d recommend a Code by Zapier step, with a Javascript event set up as in the screenshot (using the copy/paste code below):

var input = inputData.input;

var output = input.replace(/,\s/g, "\n");

output = [{output}];

As you can see from the below screenshots, it works with any number of line items (so long as they don’t have a comma followed by a space in their name.

 

View original
This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

5 replies

Todd Harper
Forum|alt.badge.img+8
  • Zapier Solution Partner
  • Answer
  • Nov 26, 2022 6:26 AM UTC

Hi @Eric Caldwell!

Welcome to the Zapier Community!

I’d recommend a Code by Zapier step, with a Javascript event set up as in the screenshot (using the copy/paste code below):

var input = inputData.input;

var output = input.replace(/,\s/g, "\n");

output = [{output}];

As you can see from the below screenshots, it works with any number of line items (so long as they don’t have a comma followed by a space in their name.

 


Forum|alt.badge.img

Thanks so much for the reply. Any idea why this isn’t working?

 

 


Todd Harper
Forum|alt.badge.img+8
  • Zapier Solution Partner
  • Nov 26, 2022 10:53 PM UTC

Oh, in your first example, there were spaces between each element. In this case, delete the \s from the code, and you should be set!


Todd Harper
Forum|alt.badge.img+8
  • Zapier Solution Partner
  • Nov 28, 2022 3:45 PM UTC

@Eric Caldwell Were you able to try this out?


Forum|alt.badge.img
  • Author
  • Beginner
  • Nov 29, 2022 12:38 AM UTC

I sure did! Thanks so much for the help