Best answer

line items in brackets?

  • 16 April 2020
  • 2 replies
  • 643 views

Hi There,

I am really struggling with the shopify new order trigger and line items. Probably just a me problem but hoping someone can square my head around the issue.  The trigger has line item suport but i dont understand why some line items seem to “work” (as in actually put data into a spreadsheet line by line as expected) and some seem to just puke all their data into a single cell.

My example: Processing this using the Create Spreadsheet Row(s) in Google Sheets action

 

Results in the tax lines price being put in its entirety into every row, rather than one per item as it should be:

 

I see that its in square brackets and the other line item fields are not, but i have been unable to find any help as to what that means. Sorry if this is a very basic question!

 

Thanks.

icon

Best answer by Danvers 16 April 2020, 13:49

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.

2 replies

Userlevel 7
Badge +12

Hi @Darock999, welcome to the Community! 

 

@Saastronomical is right that what you’re seeing is an array - sort of like a line item of line items.

 

There is a way that you can process the data to get it back a single set of line items (like the other data from Shopify). It’s likely that this can be done with a code step, though you can also do it using a couple of Formatter steps.

 

First, use "Line-item to text" to turn the array Shopify into a text string:

 

This will completely ‘flatten’ the array and convert the whole thing into a text string, with items separated by commas.

Then take the result of this step and run it through "Text to line-item"

 

This takes the text and turns it back into line items, that you can use in the next step. I hope that helps!

Userlevel 7
Badge +9

Hey! It’s not a basic question - You’re getting into the advanced Zapier concepts here.

Square brackets means that it’s an array of data, so if you need this on a separate line, you will need to break this array up, because as you can see -

  • Your other line items are arrays
  • But your tax line is an array of arrays

The problem is I’m not sure why it’s coming through like that from Shopify, but in to solve this you will need to find a way to turn this array of arrays  into an array of numbers

I would start simple here and use Zapier’s Transform features, perhaps just to see if you can remove the “[“ and “]” from the line -  But if that doesn’t work this might need a bit of code

Hope that helps!