Lesotho (GBP£)
Madagascar (GBP£)
return settings; } catch (e) { console.debug('STOQ - error applying translations:', e); return settings; } } function setupCartSellingPlanUpdater(settings) { window.addEventListener('stoq:inventory-data-loaded', function(event) { console.debug('STOQ - Inventory data loaded, updating cart selling plans'); if (window._RestockRocket && window._RestockRocket.updateCartSellingPlans) { window._RestockRocket.updateCartSellingPlans() .then(hasUpdates => { if (hasUpdates) { console.debug('STOQ - cart selling plans updated successfully'); } else { console.debug('STOQ - no cart selling plan updates needed'); } }) .catch(error => { console.error('STOQ - error updating cart selling plans:', error); }); } }); } function storefrontGraphql(query, variables) { const cfg = window._RestockRocketConfig; if (!cfg.storefrontAccessToken || cfg.disMali (XOFFr)
ing!, $key: String!) { shop { metafield(namespace: $namespace, key: $key) { value } } }'; return storefrontGraphql(query, { namespace: cfg.metafieldNamespace, key: key }) .then(function(data) { const value = data && data.shop && data.shop.metafield && data.shop.metafield.value; if (!value) { throw new Error('Storefront API returned no ' + key + ' metafield value'); } return JSON.parse(value); }); } function fetchStorefrontSettings() { const query = 'query StoqSettings($namespace: String!) { shop { settings: metafield(namespace: $namespace, key: "settings") { value } translations: metafield(namespace: $namespace, key: "settings_translations") { value } } }'; return storefrontGraphql(query, { namespace: window._RestockRocketConfig.metafieldNamespace }) .then(function(data) { const settings = JSON.parse(data.shop.settings.value); if (!settings.updated_at) { throw new Error('settings metafield is not a settings payload'); } if (settings.single_locale}
function initializeScripts(settings) {
settings = applyTranslations(settings);
window._RestockRocketConfig.settings = settings;
console.debug(`STOQ - settings configured for ${window._RestockRocketConfig.pageType}`);
const forceEmbedSellingPlans = settings.force_embed_selling_plans === true;
const staleRefresh = !window._RestockRocketConfig.isLiquidCacheFresh && !settings.disable_refresh_on_stale_liquid;
if (forceEmbedSellingPlans || staleRefresh) {
console.debug('STOQ - refreshing selling_plans' + (staleRefresh ? ' + integrations (Liquid cache stale)' : ' (force_embed_selling_plans)'));
const refreshes = [refreshSellingPlans(forceEmbedSellingPlans)];
if (staleRefresh) { refreshes.push(refreshIntegrations()); }
Promise.race([
Promise.all(refreshes),
new Promise(function(resolve) { setTimeout(resolve, 1000); })
]).then(function() { loadScripts(settings); });
return;
}
loadScripts(settings);
}
function loadScripts(setMalta (EUR€)
? window._RestockRocketConfig.scriptUrlProduct
: window._RestockRocketConfig.scriptUrlProductBis;
const pageType = window._RestockRocketConfig.pageType;
const collectionPageTypes = ['collection', 'index', 'search', 'page'];
if(collectionPageTypes.indexOf(pageType) !== -1 && (settings[`show_button_on_${pageType}`] || settings[`preorder_${pageType}_enabled`])) {
createRestockRocketScript(collectionScriptUrl);
} else if(pageType === 'product') {
createRestockRocketScript(productScriptUrl);
} else if(hijackIntegration) {
createRestockRocketScript(window._RestockRocketConfig.scriptUrlCollection);
} else if(usePreorderBuild) {
createRestockRocketScript(window._RestockRocketConfig.scriptUrlCollection);
} else {
console.debug(`STOQ - no scripts enabled for ${pageType}`);
}
const appLoadedEvent = new CustomEvent('stoq:loaded', {
detail: {
pageType: window._RestockRocketConfig.pageType,
Mauritania (GBP£)







