Skip to content

Instantly share code, notes, and snippets.

View gmbarroso's full-sized avatar
🎯
Focusing

gmbarroso gmbarroso

🎯
Focusing
View GitHub Profile
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 => {
const orderJSON = require('./order.json');
let arrayOfItems = []
let arrayOfItemsAsString = []
let url = ""
const sc = orderJSON.content.salesChannel
const account = orderJSON.content.items[0].catalogProvider.split(":")
const items = Object.values(orderJSON.content.items).map(value => value.id)
arrayOfItems = items.map(value => {
const url = "https://raiadrogasil.myvtex.com/checkout/cart/add/?sku=70288&qty=1&seller=1&sc=1?sku=12345&qty=1&seller=1&sc=1?sku=10253&qty=1&seller=1&sc=1"
let items = []
const parameters = url.match(/\A?sku=[^&]+&\A?qty=[^&]+&*\A?seller=[^&]+&*/g)
console.log(parameters)
simulation = parameters.map(value => {
let obj = {
"id": value.match(/([\d]+)/g)[0],
"quantity": value.match(/([\d]+)/g)[1],
"seller": "1"
const orderJSON = require('./order.json');
let simulation = {}
let arrayOfItems = []
const items = Object.values(orderJSON.content.items).map(value => {
let obj = {
"id": value.id,
"quantity": value.quantity,
"seller": "1"
}
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 = {