• Instructions to Ask a Question

    Click on the "Ask a Question" button and select the application for which you would like to ask questions.

    We have 5 different products namely - Pabbly Connect, Pabbly Subscription Billing, Pabbly Email Marketing, Pabbly Form Builder, Pabbly Email Verification.

    The turnaround time is 24 hrs (Business Hours - 10.00 AM to 6.00 PM IST, Except Saturday and Sunday). So your kind patience will be highly appreciated!

    🚀🚀Exclusive Discount Offer

    Just in case you're looking for any ongoing offers on Pabbly, you can check the one-time offers listed below. You just need to pay once and use the application forever -
     

    🔥 Pabbly Connect One Time Plan for $249 (🏆Lifetime Access) -  View offer 

    🔥 Pabbly Subscription Billing One Time Plan for $149 (🏆Lifetime Access) - View offer

Line Items data from Woocommerce Order not passing to WhatsApp message template - simply says "Array"?

Hi I have a workflow where im trying to capture woocommerce orders and send them to myself via WhastApp Cloud API in a message template.

So far I have successfully set it all up and managed to get the template approved and passed acros the order id, the date of the order, the customer name, phone number and delivery address, and the total price.

The only part that isnt working are the details of the actual items ordered from the Line Items in the Woocommerce order.
When I map and send this over in a whatsapp message, it simply says "Array", and no order details are included.

I have searched the forum to find how to format the Line Items so that I can send them in rows in the message template.

I need to convert this:

[{"id":77,"name":"Porterhouse Steak \/ T-Bone Steak","product_id":208,"variation_id":0,"quantity":2,"tax_class":"","subtotal":"49.96","subtotal_tax":"0.00","total":"49.96","total_tax":"0.00","taxes":[],"meta_data":[],"sku":"","price":24.98,"image":{"id":"209","src":"https:\/\/chadwicksfarmshop.co.uk\/wp-content\/uploads\/2021\/01\/t-bone-steak.jpg"},"parent_name":null},{"id":78,"name":"Rump Steak","product_id":1857,"variation_id":0,"quantity":2,"tax_class":"","subtotal":"43.96","subtotal_tax":"0.00","total":"43.96","total_tax":"0.00","taxes":[],"meta_data":[],"sku":"","price":21.98,"image":{"id":"1858","src":"https:\/\/chadwicksfarmshop.co.uk\/wp-content\/uploads\/2023\/10\/PHOTO-2023-10-20-08-31-50.jpg"},"parent_name":null},{"id":79,"name":"Cumberland Sausages","product_id":1209,"variation_id":0,"quantity":1,"tax_class":"","subtotal":"4.50","subtotal_tax":"0.00","total":"4.50","total_tax":"0.00","taxes":[],"meta_data":[],"sku":"","price":4.5,"image":{"id":"1195","src":"https:\/\/chadwicksfarmshop.co.uk\/wp-content\/uploads\/2023\/09\/PHOTO-2023-09-27-20-23-23.jpg"},"parent_name":null}]

to this:
2 x Porterhouse Steak £46.96
2 x Rump Steak £43.96
1 x Sausages £4.50

and then send that as a single value to the message template.
Please can someone explain clearly how to do this, im running out of time to get this working, otherwise I will have to cancel and get a refund,
but I don't want to do that, I want to get Pabbly Connect sending my orders to me via WhatsApp.
 

ArshilAhmad

Moderator
Staff member
Hi @LondonWebDesignCompany,

While there isn't a direct tool available for converting the data into the required format, we are actively working on finding a workaround. I kindly request you to allow us some more time, and we will provide you with an update soon.
 
You seem to have tools that would do half the job already, such as the tools used to export orders to Google Sheets, perhaps adding an option to the text formatter to you just need to nap & then save the values locally and make them available to map to the WhatsApp Cloud API message template as a single value.

Or another option is to modify the tool used to pass orders to ChatApi to format & save the LineItem data as a value that can be passed to WhatsApp Cloud API?

How long will you need to provide a working solution? I should have had this up & running a couple of weeks ago & ive run out of time.
 
Last edited:

ArshilAhmad

Moderator
Staff member
You seem to have tools that would do half the job already, such as the tools used to export orders to Google Sheets, perhaps adding an option to the text formatter to you just need to nap & then save the values locally and make them available to map to the WhatsApp Cloud API message template as a single value.

Or another option is to modify the tool ised to pass orders to ChatApi to format & save the LineItem data as a value that can be passed to WhatsApp Cloud API?
The current tools we have will not work for your use case because the number and type of items you receive from WooCommerce vary with each order. Additionally, you want the JSON to be converted to a specific format. These combined factors requires a more customized solution for your use case.

How long will you need to provide a working solution? I should have had this up & running a couple of weeks ago & ive run out of time.
I request you to please allow us some more time. We will provide you with a workaround as soon as possible.
 

ArshilAhmad

Moderator
Staff member
Please use this Python code along with the Text Formatter to achieve your desired format.

Python:
data = [
    {"id": 77, "name": "Porterhouse Steak / T-Bone Steak", "product_id": 208, "variation_id": 0, "quantity": 2, "tax_class": "", "subtotal": "49.96", "subtotal_tax": "0.00", "total": "49.96", "total_tax": "0.00", "taxes": [], "meta_data": [], "sku": "", "price": 24.98, "image": {"id": "209", "src": "https://chadwicksfarmshop.co.uk/wp-content/uploads/2021/01/t-bone-steak.jpg"}, "parent_name": None},
    {"id": 78, "name": "Rump Steak", "product_id": 1857, "variation_id": 0, "quantity": 2, "tax_class": "", "subtotal": "43.96", "subtotal_tax": "0.00", "total": "43.96", "total_tax": "0.00", "taxes": [], "meta_data": [], "sku": "", "price": 21.98, "image": {"id": "1858", "src": "https://chadwicksfarmshop.co.uk/wp-content/uploads/2023/10/PHOTO-2023-10-20-08-31-50.jpg"}, "parent_name": None},
    {"id": 79, "name": "Cumberland Sausages", "product_id": 1209, "variation_id": 0, "quantity": 1, "tax_class": "", "subtotal": "4.50", "subtotal_tax": "0.00", "total": "4.50", "total_tax": "0.00", "taxes": [], "meta_data": [], "sku": "", "price": 4.5, "image": {"id": "1195", "src": "https://chadwicksfarmshop.co.uk/wp-content/uploads/2023/09/PHOTO-2023-09-27-20-23-23.jpg"}, "parent_name": None}
]

output = []

for item in data:
    quantity = item["quantity"]
    name = item["name"].split(" / ")[0].strip()  # Extract the name before "/"
    total = item["total"]
    output.append(f"{quantity} x {name} £{total}")

output = '\/n'.join(output)
print(output)

Follow the exact steps given below.
1698268260160.png



 

Himesh

Active member
You can also do this only using one step.
Select Action->Code->Javascript and then paste this code
const orders = [
{"id": 77, "name": "Porterhouse Steak / T-Bone Steak", "product_id": 208, "variation_id": 0, "quantity": 2, "tax_class": "", "subtotal": "49.96", "subtotal_tax": "0.00", "total": "49.96", "total_tax": "0.00", "taxes": [], "meta_data": [], "sku": "", "price": 24.98, "image": {"id": "209", "src": "https://chadwicksfarmshop.co.uk/wp-content/uploads/2021/01/t-bone-steak.jpg"}, "parent_name": null},
{"id": 78, "name": "Rump Steak", "product_id": 1857, "variation_id": 0, "quantity": 2, "tax_class": "", "subtotal": "43.96", "subtotal_tax": "0.00", "total": "43.96", "total_tax": "0.00", "taxes": [], "meta_data": [], "sku": "", "price": 21.98, "image": {"id": "1858", "src": "https://chadwicksfarmshop.co.uk/wp-content/uploads/2023/10/PHOTO-2023-10-20-08-31-50.jpg"}, "parent_name": null},
{"id": 79, "name": "Cumberland Sausages", "product_id": 1209, "variation_id": 0, "quantity": 1, "tax_class": "", "subtotal": "4.50", "subtotal_tax": "0.00", "total": "4.50", "total_tax": "0.00", "taxes": [], "meta_data": [], "sku": "", "price": 4.5, "image": {"id": "1195", "src": "https://chadwicksfarmshop.co.uk/wp-content/uploads/2023/09/PHOTO-2023-09-27-20-23-23.jpg"}, "parent_name": null}
];

let formattedOutput = '';
for (const order of orders) {
const { quantity, name, total } = order;
formattedOutput += `${quantity} x ${name} £${total}\n`;
}

return formattedOutput;


1698295384825.png
 
Top