Skip to main content
Best answer

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

  • November 25, 2022
  • 5 replies
  • 73 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 HarperBest 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
Did this topic help you find an answer to your question?
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 Expert
  • 197 replies
  • Answer
  • November 26, 2022

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
  • Author
  • Beginner
  • 11 replies
  • November 26, 2022

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

 

 


Todd Harper
Forum|alt.badge.img+8
  • Zapier Expert
  • 197 replies
  • November 26, 2022

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 Expert
  • 197 replies
  • November 28, 2022

@Eric Caldwell Were you able to try this out?


Forum|alt.badge.img
  • Author
  • Beginner
  • 11 replies
  • November 29, 2022

I sure did! Thanks so much for the help