Skip to main content

Hi, 

 

I’m getting stuck with the JS code. Basically I’m getting single line of order from WooCommerce, counting the quantity of products for this line and creating number of rows in Google Sheets that equals the quantity. 

In order to do this I’ve created Code block that should return line items that can be used later to create Google Sheet record. 

My code is here:

The test runs gives such output :

 

However in following step - creating Google Sheets record - I’m not getting Line item support:

only separete lines. So runnig this zap will create only one row in Google Sheet. 

What am I doing wrong? 

 

@Danvers - Sure, I will try and help :)

@Marcin - That issue you’re seeing is basically due to your use of an object that is 1-based indexed. Thus, in order to get line items to work as expected, you should actually use an array. Take a look at the code snippet below:

const items = s]

for (let i = 1; i <= parseInt(inputData.iloscPokoi); i++) {
items.push({
nr_projektu: inputData.nrProjektu,
rodzaj: inputData.rodzajPokoju,
nr_pokoju_w_zamowjeniu: i,
klient: inputData.klient
})
}

output = t{ items }]

 


Hi @Marcin! Hmm, you’re right, it looks like the line items have been made correctly given the output of the code step. I wonder if anyone who has experience with code steps is able to help here, maybe @ikbelkirasan?