Hey, I need help ASAP with this:( There’s an online shop. I receive data by the HTTP module. Then I parse JSON. In that JSON data, I can have a lot of different products. Each product with details is a separate bundle. I can’t figure out how to put them all together!
I need a string like this:
“product1, quantity1, price1
product2, quantity2, price2”
And as many as there are products. Can’t figure it out:(
Hi @Valeriya_Ensenat
With the information given I would say try adding an Iterator module to iterate through the bundles and then a Text Aggregator module to create your string, mapping each component of your string: product, quantity, price
If you enable Show Advanced Settings at the bottom of the Text Aggregator, you can put each bundle output on a separate line in your string.
Hi! Yes, that does help! The issue is that right now the data looks like on the screenshot. Out of that, I need to somehow make a string of “product1, quantity1, price1 ; product2, quantity2, price2 … productN, quantityN, priceN”, so take out only certain data (e.g. name)
In your Text Aggregator, make sure you set the Iterator as your source module, then create your text string using elements from your iterator output (in green). It will look something like this:
That looks like a CSV (Comma-Separated Value) format.
You should use the “Create CSV” module for this, not a text aggregator.
Can you provide the output bundles of this module? Click the white speech bubble on the top-right of the module, save the bundle contents in your text editor as a bundle.json file, and upload it here into this discussion thread.
Providing the output bundles will allow others to replicate what is going on in the scenario even if they do not use the external service.
This will allow others to better assist you. Thanks!
In that file, the products info I need are “name”, “price_sold” and “quantity”. There are 2 products (2 id). so I would need each row to have that info. There is no way to predict how many products there will be.
I use the “|” character in one of my modules to help manage text blobs of records, and then use split function {{split(1.blob; “|”)}} to string them out again for processing. so you could take the order from the ecommerce feed, iterate the line items and extract the specific fields you need, mark the end of the blob with “|”, and the aggregate them into a variable for storage.
Take the JSON structure from the line items, create a disabled branch with route, use JSON create and add to a dummy variable. then when you aggregate, you can point the aggregator to this structure to create the data blob for you.
As per example - the aggregator points to the JSON structure contained in the “create the invoice bundle” function.
That sounds great! How did you manage when you have more than one bundle? In you screenshot you have shipping, how do you manage when you have more than one shipping_surname etc?
I make use of the MAKE native DATA STORE when transforming data sets. So let us assume you are receiving WooCommerce JSON posts. the line items is another array in the JSON post structure. you can easily use the data store, with the order_id as your primary key, and have a line item array attached to this record that you can manipulate. you can then search and iterate from the store again if need be. delete the record when done.