Hi,
Thanks for all the efforts being put to come up with such a wonderful solution. We have been trying to use n8n to do some automation between Woocommerce and ERPNext. Out of the box, the new order trigger isn’t passing some of elements created by 3rd party plugins (booking activities), and also doesnt provide details for product variation (product attributes). We are trying to implement a work-around where ERPNext will trigger a call to webhook upon new entry in the (sales order item) to grab the missing elements and insert them into a custom field part of the sales order item (notes).
However, we are facing a challenge as the meta_data for the line_items has one field which contains the booking data as list in the json output below, we need to extract the Event data for every item_list where the key equals to bookacti_bookings (Event:Morning Tour - Friday, November 12th, 2021 8:00 AM → 11:00 AM x1).
{
"id": 203,
"key": "bookacti_bookings",
"value": "[{\"id\":154,\"type\":\"single\"}]",
"display_key": "Booking",
"display_value": "Booking ID:154Status:PendingEvent:Morning Tour - Friday, November 12th, 2021 8:00 AM → 11:00 AM x1"
}
Also, for product variations, we are interested in the details of the product attributes Kayak Type and Duration as shown below.
"meta_data": [
{
"id": 213,
"key": "pa_kayak-type",
"value": "single-kayak",
"display_key": "Kayak Type",
"display_value": "Single"
},
{
"id": 214,
"key": "pa_duration",
"value": "1-hour",
"display_key": "Duration",
"display_value": "1 Hour"
}
]
Provided below the json output, appreciate your guidance and support, thanks in advance…
{
"id": 1234,
"parent_id": 0,
"status": "on-hold",
"currency": "OMR",
"version": "5.8.0",
"prices_include_tax": false,
"date_created": "2021-11-08T04:28:40",
"date_modified": "2021-11-08T04:28:40",
"discount_total": "0.000",
"discount_tax": "0.000",
"shipping_total": "0.000",
"shipping_tax": "0.000",
"cart_tax": "0.000",
"total": "110.000",
"total_tax": "0.000",
"customer_id": 2,
"order_key": "wc_order_xxxxxxxxx",
"billing": {
"first_name": "YOUS H",
"last_name": "ALI",
"company": "",
"address_2": "",
"city": "Muscat",
"state": "MUSCAT",
"postcode": "115",
"country": "OM",
},
"shipping": {
"first_name": "",
"last_name": "",
"company": "",
"address_1": "",
"address_2": "",
"city": "",
"state": "",
"postcode": "",
"country": "",
"phone": ""
},
"payment_method": "bacs",
"payment_method_title": "Direct bank transfer",
"transaction_id": "",
"date_completed": null,
"date_paid": null,
"cart_hash": "xxxxxxxxxxxxxxxxxxx",
"number": "1234",
"meta_data": [
{
"id": 12588,
"key": "is_vat_exempt",
"value": "no"
},
{
"id": 12592,
"key": "_wcpdf_invoice_settings",
"value": {
"enabled": "1",
"attach_to_email_ids": {
"new_order": "1",
"customer_completed_order": "1",
"customer_invoice": "1"
},
"display_shipping_address": "",
"display_email": "1",
"display_phone": "1",
"display_customer_notes": "1",
"display_date": "order_date",
"display_number": "invoice_number",
"number_format": {
"prefix": "[invoice_year]-[invoice_month]- ",
"suffix": "",
"padding": ""
},
"reset_number_yearly": "1",
"my_account_buttons": "available",
"invoice_number_column": "1",
"disable_free": "1",
"use_latest_settings": "1",
"paper_size": "a4",
"font_subsetting": false,
"header_logo": "666",
"header_logo_height": "",
"shop_name": {
"default": "Oman LLC"
},
"shop_address": {
"default": "Marina Muttrah, Sultanate of Oman"
},
"footer": {
"default": "This booking is subject to our terms and conditions. By reserving this activity or trip you agree to the terms and conditions detailed on our website (http:\/\/capitano.om\/terms-and-conditions)."
},
"extra_1": {
"default": ""
},
"extra_2": {
"default": ""
},
"extra_3": {
"default": ""
}
}
},
{
"id": 12593,
"key": "_wcpdf_invoice_date",
"value": "1636331320"
},
{
"id": 12594,
"key": "_wcpdf_invoice_date_formatted",
"value": "2021-11-08 04:28:40"
},
{
"id": 12595,
"key": "_wcpdf_invoice_number",
"value": "2021-11- 9"
},
{
"id": 12596,
"key": "_wcpdf_invoice_number_data",
"value": {
"number": 9,
"formatted_number": "2021-11- 9",
"prefix": "[invoice_year]-[invoice_month]- ",
"suffix": "",
"document_type": "invoice",
"order_id": 1234,
"padding": ""
}
},
{
"id": 12597,
"key": "_new_order_email_sent",
"value": "true"
}
],
"line_items": [
{
"id": 19,
"name": "Al Khayran Tour",
"product_id": 116,
"variation_id": 0,
"quantity": 1,
"tax_class": "",
"subtotal": "100.000",
"subtotal_tax": "0.000",
"total": "100.000",
"total_tax": "0.000",
"taxes": [],
"meta_data": [
{
"id": 203,
"key": "bookacti_bookings",
"value": "[{\"id\":154,\"type\":\"single\"}]",
"display_key": "Booking",
"display_value": "Booking ID:154Status:PendingEvent:Morning Tour - Friday, November 12th, 2021 8:00 AM → 11:00 AM x1"
}
],
"sku": "CO-ADV-02",
"price": 100,
"parent_name": null
},
{
"id": 20,
"name": "Kayaking",
"product_id": 726,
"variation_id": 735,
"quantity": 1,
"tax_class": "",
"subtotal": "10.000",
"subtotal_tax": "0.000",
"total": "10.000",
"total_tax": "0.000",
"taxes": [],
"meta_data": [
{
"id": 213,
"key": "pa_kayak-type",
"value": "single-kayak",
"display_key": "Kayak Type",
"display_value": "Single"
},
{
"id": 214,
"key": "pa_duration",
"value": "1-hour",
"display_key": "Duration",
"display_value": "1 Hour"
}
],
"sku": "CO-ACT-03-11",
"price": 10,
"parent_name": "Kayaking"
}
],
"tax_lines": [],
"shipping_lines": [],
"fee_lines": [],
"coupon_lines": [],
"refunds": [],
"date_created_gmt": "2021-11-08T00:28:40",
"date_modified_gmt": "2021-11-08T00:28:40",
"date_completed_gmt": null,
"date_paid_gmt": null,
"currency_symbol": "OMR",
"_links": {
"self": [
{
}
],
"collection": [
{
}
],
"customer": [
{
}
]
}
}