Last active
November 18, 2021 16:29
-
-
Save gmbarroso/0c5bfabec76fbf2d53df243b9861a3d3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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