settings;
});
}
const cachedSettings = window._RestockRocketConfig.cachedSettings;
const validCachedSettings = cachedSettings ? checkSettingsExpiry(cachedSettings) : null;
if (validCachedSettings) {
console.debug('STOQ - using cached settings');
initializeScripts(validCachedSettings);
} else {
console.debug('STOQ - fetching fresh settings');
const headers = {
'X-Shopify-Shop-Domain': window._RestockRocketConfig.shop || window.Shopify.shop,
'ngrok-skip-browser-warning': 'skip'
};
if (window.Shopify?.theme?.role === 'main') {
headers['X-Shopify-Theme-Schema-Name'] = window.Shopify.theme.schema_name;
headers['X-Shopify-Theme-Schema-Version'] = window.Shopify.theme.schema_version;
headers['X-Shopify-Theme-Store-Id'] = window.Shopify.theme.theme_store_id;
}
const storefrontRead = window._RestockRocketConfig.readFlags?.enable_storefront_settings_read === true
? Promise.race([
fetchStorefrontSettings(),
new Promi
}
})
.catch(function(e) {
console.error(e)
})
}
function fetchEmbedConfig(endpoint, apply) {
return fetch(
`${window._RestockRocketConfig.host}/api/v1/embed/${endpoint}.json`,
{
headers: {
'X-Shopify-Shop-Domain': window._RestockRocketConfig.shop || window.Shopify.shop,
'ngrok-skip-browser-warning': 'skip'
}
}
)
.then(function(response) {
if (!response.ok) throw new Error(`Failed to fetch ${endpoint}`);
return response.json();
})
.then(function(data) {
try {
apply(data);
} catch (applyError) {
console.error('STOQ - apply failed for ' + endpoint + ':', applyError);
throw applyError;
}
})
.catch(function(error) {
console.debug(`STOQ - using cached ${endpoint}:`, error.message);
});
}
function refreshShopConfig(source) {
const cfg = window._RestockRocketConfig;
const viaEmbed = function() { return fetchEmbedConfig(source.endpoint,
a) {
cfg.integrations = data;
}
});
}
function refreshSellingPlans(embedOnly) {
const cfg = window._RestockRocketConfig;
return refreshShopConfig({
embedOnly: embedOnly === true,
endpoint: 'selling_plans',
metafieldKey: 'cachedSellingPlans',
flag: 'enable_storefront_selling_plans_read',
isValid: function(value) { return !!value && Array.isArray(value.plans); },
apply: function(data) {
cfg.sellingPlans = data.plans;
cfg.disabledSellingPlanIds = data.disabled_plan_ids || [];
if (data && data.read_flags && typeof data.read_flags === 'object' && !Array.isArray(data.read_flags)) {
cfg.readFlags = data.read_flags;
}
}
});
}
function initializeScripts(settings) {
settings = applyTranslations(settings);
window._RestockRocketConfig.settings = settings;
console.debug(`STOQ - settings configured for ${window._RestockRocketConfig.pageType}`);
const forceEmbedSellingPlans = settings.foMaintenance
Shop by Brand
North Macedonia (MKDден)
Réunion (EUR€)
Senegal (XOFFr)
Burkina Faso (XOFFr)
Stems
Greenland (DKKkr.)
ncludes(window._RestockRocketConfig.pageType);
})
const hasEnabledOffer = Array.isArray(window._RestockRocketConfig.sellingPlans)
&& window._RestockRocketConfig.sellingPlans.some(function(plan) { return plan && plan.enabled; });
const hasDisabledPlanIds = Array.isArray(window._RestockRocketConfig.disabledSellingPlanIds)
&& window._RestockRocketConfig.disabledSellingPlanIds.length > 0;
const usePreorderBuild = settings.preorder_enabled || hasEnabledOffer || hasDisabledPlanIds;
const pageType = window._RestockRocketConfig.pageType;
const preorderUiOnPage = (settings.preorder_enabled && settings[`preorder_${pageType}_enabled`])
|| window._RestockRocketConfig.integrations.some(function(integration) {
return (integration.type === 'quick_buy' || integration.type === 'featured_product')
&& integration.enabled && integration.page_types.includes(pageType);
})
|| /\b(renderPreorderButton|updateAddToCartButton|updateAddToC
Electric BikesAndorra (EUR€)
Algeria (DZDد.ج)
Netherlands (EUR€)
Armenia (AMDդր.)
See MoreAscension Island (SHP£)
Velduro
Kona
Central African Republic (XAFCFA)
Slovenia (EUR€)
Second-Hand BikesChad (XAFCFA)
Somalia (GBP£)
Cycle To Work Schemes
Uganda (UGXUSh)
Ukraine (UAH₴)
United Kingdom (GBP£)
Finland (EUR€)
Parts & Components
Comoros (KMFFr)
Eswatini (GBP£)
- Shop All Second-Hand South Africa (GBP£) Congo - Brazzaville (XAFCFA)
- Custom Builds South Sudan (GBP£) See MoreCongo - Kinshasa (CDFFr)
- Spain (EUR€) Custom Builds for saleCôte d’Ivoire (XOFFr) St. Helena (SHP£) Custom Build Inspiration
- Croatia (EUR€) Sudan (GBP£) Cyprus (EUR€)
- Services Svalbard & Jan Mayen (GBP£) See More Czechia (CZKKč)
- Sweden (SEKkr) WorkshopDenmark (DKKkr.) See More
- Switzerland (CHFCHF) Djibouti (DJFFdj) Workshop Prices Tanzania (TZSSh)
- Egypt (EGPج.م) Book a Service Togo (XOFFr) Track Your ServiceEquatorial Guinea (XAFCFA)
- Tristan da Cunha (GBP£) OtherEritrea (GBP£)
- See More Tunisia (GBP£) Estonia (EUR€) Custom Builds
Gibraltar (GBP£)
Grips & Bar-Tape
HeadsetsGreece (EUR€)
Greenland (DKKkr.)
| Guadeloupe (EUR€) | See More|
|---|---|
| Brake RotorsGuinea (GNFFr) | |
| Guinea-Bissau (XOFFr) | Brake Spares |
| Forks | See MoreIceland (ISKkr) |
| Front SuspensionIreland (EUR€) | Rear Suspension |
| Italy (EUR€) | |
| See MoreJersey (GBP£) | |
| Tubes | Kosovo (EUR€) |
| Saddles | |
| Pedals | |
| Gears & Drivetrain | |
| Components | |
| Wheels | See More |
| Complete Wheels | |
| Tubeless | |
| Tools & Maintenance | |
| Clothing and Protection | See More |
| ProjektRide Merchandise | |
| Gloves | |
| Socks | |
| = 0); }); } else { _sqArm = (_sqc.integrations || []).some(function (i) { return i && i.type === 'featured_product' && i.enabled && Array.isArray(i.page_types) && i.page_types.indexOf(_sqc.pageType) !== -1; }); } } if (_sqArm && document.documentElement) { _sqc.acceleratedGateArmed = true; document.documentElement.classList.add('stoq-buy-now-pending'); setTimeout(function () { document.documentElement.classList.remove('stoq-buy-now-pending'); }, 6000); } } catch (e) { } window._RestockRocketConfig.scriptUrlProduct = 'https://cdn.shopify.com/extensions/01a1b3f4-12aa-7f20-af90-2397b6140bd7/restockrocket-1-636/assets/restockrocket-product.js' window._RestockRocketConfig.scriptUrlCollection = 'https://cdn.shopify.com/extensions/01a1b3f4-12aa-7f20-af90-2397b6140bd7/restockrocket-1-636/assets/restockrocket-collection.js' window._RestockRocketConfig.scriptUrlCollectionFull = 'https://cdn.shopify.com/extensi | tch (e) { window._RestockRocketConfig.appVersion = ''; } const SETTINGS_CACHE_DURATION = 15 * 60 * 1000; const LIQUID_CACHE_MAX_AGE = 15 * 60; const liquidRenderedAt = window._RestockRocketConfig.liquidRenderedAt; if (!liquidRenderedAt || typeof liquidRenderedAt !== 'number' || isNaN(liquidRenderedAt)) { console.debug('STOQ - Invalid or missing liquidRenderedAt timestamp, assuming fresh'); window._RestockRocketConfig.isLiquidCacheFresh = true; window._RestockRocketConfig.liquidCacheAge = null; } else { const now = Math.floor(Date.now() / 1000); const liquidCacheAge = now - liquidRenderedAt; window._RestockRocketConfig.liquidCacheAge = Math.max(0, liquidCacheAge); if (liquidCacheAge0) { console.debug(`STOQ - Client clock appears ahead of server by ${Math.abs(Math.round(liquidCacheAge / 60))} minutes, assuming cache fresh`); window._RestockRocketConfig.isLiquidCacheFresh = true; } else if (liquidCacheAge Essentials | = LIQUID_CACHE_MAX_AGE) { console.debug(`STOQ - Liquid cache is fresh (${Math.round(liquidCacheAge / 60)} minutes old)`); window._RestockRocketConfig.isLiquidCacheFresh = true; } else { console.debug(`STOQ - Liquid cache is stale (${Math.round(liquidCacheAge / 60)} minutes old, max ${Math.round(LIQUID_CACHE_MAX_AGE / 60)} minutes)`); window._RestockRocketConfig.isLiquidCacheFresh = false; } } function checkSettingsExpiry(settings) { try { if (!settings || !settings.updated_at) { console.debug('STOQ - Invalid settings data structure'); return null; } if (!settings.cache) { console.debug('STOQ - settings caching disabled'); return null; } if (settings.multi_language_enabled) { if (!settings.translations) { console.debug('STOQ - multi-language enabled but no translation data in cache, fetching fresh'); return null; } if (window._RestockRocketConfig.normalizedLocale &.closest('.shopify-payment-button, shopify-payment-terms'); if (!host) return; var channel = host.matches && host.matches('shopify-payment-terms') ? 'shop_pay_installments' : 'buy_now'; var form = host.closest('form'); var vidEl = form && form.querySelector('[name="id"]'); var variantId = (vidEl && vidEl.value) || _sqTrack.selected_variant_id || ''; var _sqVidNum = Number(variantId); var _sqPlan = null; var _sqPlans = Array.isArray(_sqTrack.sellingPlans) ? _sqTrack.sellingPlans : []; var _sqMktId = Number(_sqTrack.marketId); var _sqOffersOn = !!(_sqTrack.readFlags && _sqTrack.readFlags.enable_storefront_plan_offers === true); var _sqAlloc = _sqOffersOn ? ((_sqTrack.offerAllocations && _sqTrack.offerAllocations[_sqVidNum]) || (_sqTrack.variantSellingPlanIds && _sqTrack.variantSellingPlanIds[_sqVidNum])) : null; var _sqPlanIds = function (pl) | _sqPlans.forEach(function (pl) { if (!_sqPlan && _sqForVariant(pl) && !pl.markets_enabled) { _sqPlan = pl; } }); } Shopify?.analytics?.publish?.('stoq_accelerated_checkout_clicked', { variant_id: variantId, product_id: (_sqTrack.product && _sqTrack.product.id) || '', channel: channel, market_id: _sqTrack.marketId || '', country_code: _sqTrack.countryIsoCode || '', page_type: _sqTrack.pageType || '', cart_token: _sqTrack.cartToken || '', page_url: (window.location && window.location.origin + window.location.pathname) || '', properties: { is_preorder_variant: (function () { var vid = Number(variantId); var has = function (a) { return Array.isArray(a) && a.indexOf(vid) !== -1; }; return has(_sqTrack.preorderVariantIds) || has(_sqTrack.cachedPreorderVariantIds &&| se(function(_, reject) { setTimeout(function() { reject(new Error('timed out')); }, 1500); })
]).catch(function(error) {
console.debug('STOQ - Storefront settings read failed, using setting.json:', error.message);
})
: Promise.resolve();
storefrontRead
.then(function(settings) {
return settings || fetch(
`${window._RestockRocketConfig.host}/api/v1/setting.json?translation_locale=${window._RestockRocketConfig.normalizedLocale}`,
{ headers }
)
.then(function(response) {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
});
})
.then(function(settings) {
initializeScripts(settings);
})
.catch(function(error) {
if (cachedSettings) {
console.debug('STOQ - using expired cached settings as fallback');
initializeScripts(cachedSettings);
} else {
console.error('STOQ - failed to load settings:', error);
| source.apply); };
const flagOn = !!cfg.readFlags && cfg.readFlags[source.flag] === true;
if (!flagOn || source.embedOnly === true) { return viaEmbed(); }
return fetchStorefrontShopMetafield(source.metafieldKey)
.then(function(value) {
if (!source.isValid(value)) { throw new Error(source.metafieldKey + ' metafield is not a valid ' + source.endpoint + ' payload'); }
source.apply(value);
console.debug('STOQ - refreshed ' + source.endpoint + ' from the Storefront API');
})
.catch(function(error) {
console.debug('STOQ - Storefront ' + source.endpoint + ' read failed, using embed:', error.message);
return viaEmbed();
});
}
function refreshIntegrations() {
const cfg = window._RestockRocketConfig;
return refreshShopConfig({
endpoint: 'integrations',
metafieldKey: 'integrations',
flag: 'enable_storefront_integrations_read',
isValid: function(value) { return Array.isArray(value); },
apply: function(dat
rce_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(settings) {
setupCartSellingPlanUpdater(settings);
if(settings.enable_app) {
const hijackIntegration = window._RestockRocketConfig.integrations.find(function(integration) {
return integration.type === 'hijack' && integration.enabled && integration.page_types.iMaintenance | artForms|setupAddToCartForm|teardownAddToCartForm|addDiscountedPrice|removeDiscountedPrice)\b/.test(settings.js_config || '');
const preorderCollectionScriptUrl = preorderUiOnPage
? window._RestockRocketConfig.scriptUrlCollectionFull
: window._RestockRocketConfig.scriptUrlCollection;
const collectionScriptUrl = usePreorderBuild
? preorderCollectionScriptUrl
: window._RestockRocketConfig.scriptUrlCollectionBis;
const productScriptUrl = usePreorderBuild
? window._RestockRocketConfig.scriptUrlProduct
: window._RestockRocketConfig.scriptUrlProductBis;
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(hijackIntegra
|
Sell Your Bike |
|
Finance |
|
|
| Log in
|
|
|
|
|
|
GBP£ |
Åland Islands (EUR€)
|
|
|
Algeria (DZDد.ج)
| |






See More
Helmets
Contact Us





Albania (ALLL)
Namibia (GBP£)