Skip to content

Instantly share code, notes, and snippets.

@gmbarroso
Last active November 18, 2021 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gmbarroso/0c5bfabec76fbf2d53df243b9861a3d3 to your computer and use it in GitHub Desktop.
Save gmbarroso/0c5bfabec76fbf2d53df243b9861a3d3 to your computer and use it in GitHub Desktop.
javascript: (function () {
if (window.location.href.indexOf("/admin/checkout/#/orders/") > 1) {
const orderId = window.location.hash.split('?')[0].split('/').pop();
console.log("================== get data...");
fetch(`/api/oms/pvt/orders/${orderId}`).then(order => order.json()).then(order => {
console.log("omsOrder", order);
getPostalCode = order.shippingData.address.postalCode;
getCountry = order.shippingData.address.country;
items = Object.values(order.items).map(value => {
let obj = {
"id": value.id,
"quantity": value.quantity,
"seller": "1"
};
return obj;
});
console.log("orderItems", JSON.stringify(items));
simulation = {
"items": items,
"postalCode": getPostalCode,
"country": getCountry
};
console.log("simulatorJSON", JSON.stringify(simulation));
}).catch(error => console.log('omsError', error));
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment