Last active
September 23, 2020 15:05
-
-
Save jmwind/e34f2ee5e7c39b9ef7e9e9c65e43f241 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 jsonQ = require('jsonq'); | |
const fetch = require('node-fetch'); | |
const open = require('open'); | |
const shop_url = 'https://sc-bushfire-appeal.com'; | |
const generosity_level = 5; | |
function extractAllVariants(data) { | |
const json = jsonQ(data); | |
const products = json.find('products'); | |
const variants = products.find('variants').find('id'); | |
let variant_url = ""; | |
variants.value().forEach(id => { | |
variant_url += `${id}:${generosity_level},` | |
}); | |
const cart = `${shop_url}/cart/${variant_url}`; | |
open(cart); | |
} | |
fetch(`${shop_url}/products.json`) | |
.then(response => response.json()) | |
.then(data => extractAllVariants(data)) |
will people think im funny if i reply to jmwind github post too
thanks jm, very cool!
bruh
Nice touch on switching to template strings!
will people think im funny if i reply to jmwind github post too
nah
will people think im funny if i reply to jmwind github post too
nah
ego
Interesting use of snake case
y'all code?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you for the free shopify bot!