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 getWishlists = new Promise(async function(resolve, reject) { | |
await bigCommerce.get('/wishlists').then(data => { | |
Arr = data.data; | |
let wArr = []; | |
for (let [key, value] of Object.entries(Arr)) { | |
if (value.id) { | |
wArr.push(value.id); | |
} | |
} | |
e(); |
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
import PageManager from "./page-manager"; | |
const fetch = require('node-fetch'); | |
export default class Custom extends PageManager { | |
constructor(context) { | |
super(context); | |
this.url = window.location.href; | |
} | |
onReady(){ | |
const token = jsContext.token; |
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
--- | |
product: | |
videos: | |
limit: {{theme_settings.productpage_videos_count}} | |
reviews: | |
limit: {{theme_settings.productpage_reviews_count}} | |
related_products: | |
limit: {{theme_settings.productpage_related_products_count}} | |
similar_by_views: | |
limit: {{theme_settings.productpage_similar_by_views_count}} |
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
{{~inject 'template' template}} | |
{{inject 'token' settings.storefront_api.token}} | |
<!-- Declare an empty Array as arr | |
Then iterate over the custom fields for the intended name ('foo' here) | |
Inject into the current context --> | |
<script> | |
let jsContext = JSON.parse({{jsContext}}); | |
let arr = []; | |
{{#forEach product.custom_fields}} | |
{{#if name '===' 'foo'}} |
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
function addMultiToCart(productIds, cartId){ | |
/* Sets the URL to an existing cart id + /items, if not use the cart endpoint to create a new cart */ | |
let url = cartId ? | |
`/api/storefront/carts/${cartId}/items`: | |
`/api/storefront/cart` | |
/* Set a data variable to our lineItems object with the product ids mapped with a quantity of 1 */ | |
let data = { | |
lineItems: productIds.map(id => ({ | |
quantity: 1, | |
productId: id |
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
{{~inject 'template' template}} | |
{{inject 'token' settings.storefront_api.token}} | |
<!-- Declare an empty Array as arr | |
Then iterate over the custom fields for the intended name ('foo' here) | |
Inject into the current context --> | |
<script> | |
let jsContext = JSON.parse({{jsContext}}); | |
let arr = []; | |
{{#forEach product.custom_fields}} | |
{{#if name '===' 'foo'}} |
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
/* | |
Utility functions for rendering | |
*/ | |
// Based on the browser locale, provide a localized price | |
function formatLocalizedPrice (price) { | |
return new Intl.NumberFormat(navigator.language, {style: 'currency', currency: price.currencyCode}).format(price.value); | |
} | |
// Create a srcset string for responsive images |
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
// Routes | |
app.get("/api/login", (req, res) => { | |
// generate a constant token, no need to be fancy here | |
const token = jwt.sign({ "username": "Mike" }, jwtSecret, { expiresIn: 60 }) // 1 min token | |
// return it back | |
res.json({ "token": token }) | |
}); | |
app.get("/api/token/ping", (req, res) => { | |
// Middleware will already catch if token is invalid |
OlderNewer