Created
November 18, 2021 16:02
-
-
Save gmbarroso/cb96317868a41d81f30bc42786f7ab17 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
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 => { | |
let obj = { | |
"id": value, | |
"quantity": 1, | |
"seller": "1" | |
} | |
return obj | |
}) | |
arrayOfItemsAsString = arrayOfItems.map(value => { | |
let itemParameters = `sku=${value.id}&qty=${value.quantity}&seller=${value.seller}&sc=${sc}` | |
return itemParameters | |
}) | |
url = `https://${account[3]}.myvtex.com/checkout/cart/add/?${arrayOfItemsAsString.join("&")}` | |
console.log(url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment