Creating a WooCommerce order without manually adding each line item

Hey,

So I have some order data that gets grabbed from our ERP by a HTTP node. I want to use this data to create an order in our WooCommerce store. I tried using an expression to put in the item ID and quantity, but I quickly realised this would just create a new single item order for each product in the list.

Is there a way I can create a single order with all the items in this list without manually adding a new line item for each item part of the order?

Cheers,
Jim

Hi @jimhuds

Welcome to the community!

Yes this can be done. :slight_smile:
If you have for example 10 items from one order you can use the list items node to aggregate them into one item which would then contain an array of the order lines.
Just a quick example of splitting and aggregating items:

1 Like

Hey, thanks for the reply!

I tried inputting an array and also a comma separated list using the ‘set’ node, but both give me the error:

ERROR: Bad request - please check your parameters

Invalid parameter(s): line_items

It seems to only work when I have a list of single items, but as I say, it then makes separate orders per line on the list.

Cheers!
Jimmy

Hi,

Can you post your workflow and some dummy data we can use to help you?

Hi,

Not sure if I’ve done this correctly (didn’t know how to create the data so I’ve used ‘pin’).

Something like this?

Thats what gets the error. If I use the data without the aggregate then thats when I get multiple orders of single items.

Cheers,
Jimmy

Hi @jimhuds

I do see items but they are null.
The easiest thing would be to copy the JSON and simply paste it into a function(item) node.
Hope this makes sense.

1 Like

Hi @BramKn

How’s this?

Cheers

Hi @jimhuds

I think you are looking for something like this;

Hi,

Sorry for the delay in response. I’m still having problems with this. The last WooCommerce create:order step in the workflow you sent still requires me to create a line item for each individual line for it to work. Any ideas?

Thanks,
Jimmy