Created
November 18, 2021 16:02
-
-
Save gmbarroso/f42c90424120378ed51125cc9cd6dc8e 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); | |
account = order.hostname; | |
console.log(account); | |
sc = order.salesChannel; | |
items = Object.values(order.items).map(value => { | |
let obj = { | |
"id": value.id, | |
"quantity": value.quantity, | |
"seller": "1" | |
}; | |
return obj; | |
}); | |
arrayOfItemsAsStringWithSellersWL = items.map(value => { | |
let itemParameters = `sku=${value.id}&qty=${value.quantity}&seller=${value.seller}&sc=${sc}`; | |
return itemParameters; | |
}); | |
arrayOfItemsAsStringWithRegularSeller = items.map(value => { | |
let itemParameters = `sku=${value.id}&qty=${value.quantity}&seller=${value.seller}&sc=${sc}`; | |
return itemParameters; | |
}); | |
urlWithSellersWL = `https://${account}.myvtex.com/checkout/cart/add/?${arrayOfItemsAsStringWithSellersWL.join("&")}`; | |
urlWithRegularSeller = `https://${account}.myvtex.com/checkout/cart/add/?${arrayOfItemsAsStringWithRegularSeller.join("&")}`; | |
console.log("urlWithSellersWL", urlWithSellersWL); | |
console.log("urlWithRegularSeller", urlWithRegularSeller); | |
}).catch(error => console.log('omsError', error)); | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment