I am using Wordpress with Woocommerce platform. I must send selected order details to an API(3rd party accounting system) after an order has been successfully made.
Current jquery ajax code
j.ajax({
type: 'POST',
url: 'https://mywebsite/api/orderupload',
cache: false,
data: {
},
beforeSend:function() {
},
success: function (result) {
},
error: function(xhr,status,error) {
console.log(error);
},
complete:function(){
}
});
The structure of the json data that must be inside data {} to the post request above is:
{
"order": {
"customer": {
"type": "public",
"vat": "false",
"org_nr": "123456-789",
"name": "Carl Lorem",
"phone": "639055543227",
"address": {
"name": "Carl Lorem",
"address": "Riften Street",
"zipcode": "2323",
"city": "Dawnstar City",
"country": "US"
},
"email": "carllorem@gmail.com"
},
"transaction": {
"storage": {
"name": "Los Angeles",
"location": "Road Earth",
},
"insurance": {
"name": "Igsum Nat",
"cost": "30"
},
"date": {
"start": "2018-4-23",
"end": ""
}
}
}
}
Do you know how can I structure my json data for my post request? Any idea is appreciated. Thanks