Hand made in our Yorkshire workshop, all bags are finished with the classic Restrap label, made from vegan-friendly PU.Sold as a single unit.Weight - 710g/910g (small/large)
window.appBlockPlacements ||= [];
if (window.klarnaAppBlocksManager) {
window.klarnaAppBlocksManager.push({
productVariants: [{"id":57596176826751,"title":"50cm \/ Mellow Yellow","option1":"50cm","option2":"Mellow Yellow","option3":null,"sku":"BC-BROTHER-CYCLES-KEPLER-FRAMESET-MELLOW-YELLOW-50CM","requires_shipping":true,"taxable":true,"featured_image":null,"available":false,"name":"Brother Cycles Kepler Frameset - 50cm \/ Mellow Yellow","public_title":"50cm \/ Mellow Yellow","options":["50cm","Mellow Yellow"],"price":84900,"weight":3450,"compare_at_price":null,"inventory_management":"shopify","barcode":null,"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":57596176859519,"title":"52cm \/ Mellow Yellow","option1":"52cm","option2":"Mellow Yellow","option3":null,"sku":"BC-BROTHER-CYCLES-KEPLER-FRAMESET-MELLOW-YELLOW-52CM","requires_shipping":true,"taxable":true,"featured_image":null,"available":true,"name":"Brother Cycles Kepler Frameset - 52cm \/ Mellow Yellow","public_title":"52cm \/ Mellow Yellow","options":["52cm","Mellow Yellow"],"price":84900,"weight":3450,"compare_at_price":null,"inventory_management":"shopify","barcode":null,"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":57596176892287,"title":"54cm \/ Mellow Yellow","option1":"54cm","option2":"Mellow Yellow","option3":null,"sku":"BC-BROTHER-CYCLES-KEPLER-FRAMESET-MELLOW-YELLOW-54CM","requires_shipping":true,"taxable":true,"featured_image":null,"available":false,"name":"Brother Cycles Kepler Frameset - 54cm \/ Mellow Yellow","public_title":"54cm \/ Mellow Yellow","options":["54cm","Mellow Yellow"],"price":84900,"weight":3450,"compare_at_price":null,"inventory_management":"shopify","barcode":null,"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":57596176925055,"title":"56cm \/ Mellow Yellow","option1":"56cm","option2":"Mellow Yellow","option3":null,"sku":"BC-BROTHER-CYCLES-KEPLER-FRAMESET-MELLOW-YELLOW-56CM","requires_shipping":true,"taxable":true,"featured_image":null,"available":true,"name":"Brother Cycles Kepler Frameset - 56cm \/ Mellow Yellow","public_title":"56cm \/ Mellow Yellow","options":["56cm","Mellow Yellow"],"price":84900,"weight":3450,"compare_at_price":null,"inventory_management":"shopify","barcode":null,"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":57596176957823,"title":"58cm \/ Mellow Yellow","option1":"58cm","option2":"Mellow Yellow","option3":null,"sku":"BC-BROTHER-CYCLES-KEPLER-FRAMESET-MELLOW-YELLOW-58CM","requires_shipping":true,"taxable":true,"featured_image":null,"available":false,"name":"Brother Cycles Kepler Frameset - 58cm \/ Mellow Yellow","public_title":"58cm \/ Mellow Yellow","options":["58cm","Mellow Yellow"],"price":84900,"weight":3450,"compare_at_price":null,"inventory_management":"shopify","barcode":null,"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":57596176990591,"title":"60cm \/ Mellow Yellow","option1":"60cm","option2":"Mellow Yellow","option3":null,"sku":"BC-BROTHER-CYCLES-KEPLER-FRAMESET-MELLOW-YELLOW-60CM","requires_shipping":true,"taxable":true,"featured_image":null,"available":false,"name":"Brother Cycles Kepler Frameset - 60cm \/ Mellow Yellow","public_title":"60cm \/ Mellow Yellow","options":["60cm","Mellow Yellow"],"price":84900,"weight":3450,"compare_at_price":null,"inventory_management":"shopify","barcode":null,"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":57596177023359,"title":"50cm \/ Teal Is Real","option1":"50cm","option2":"Teal Is Real","option3":null,"sku":"BC-BROTHER-CYCLES-KEPLER-FRAMESET-TEAL-IS-REAL-50CM","requires_shipping":true,"taxable":true,"featured_image":null,"available":false,"name":"Brother Cycles Kepler Frameset - 50cm \/ Teal Is Real","public_title":"50cm \/ Teal Is Real","options":["50cm","Teal Is Real"],"price":84900,"weight":3450,"compare_at_price":null,"inventory_management":"shopify","barcode":null,"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":57596177056127,"title":"52cm \/ Teal Is Real","option1":"52cm","option2":"Teal Is Real","option3":null,"sku":"BC-BROTHER-CYCLES-KEPLER-FRAMESET-TEAL-IS-REAL-52CM","requires_shipping":true,"taxable":true,"featured_image":null,"available":true,"name":"Brother Cycles Kepler Frameset - 52cm \/ Teal Is Real","public_title":"52cm \/ Teal Is Real","options":["52cm","Teal Is Real"],"price":84900,"weight":3450,"compare_at_price":null,"inventory_management":"shopify","barcode":null,"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":57596177088895,"title":"54cm \/ Teal Is Real","option1":"54cm","option2":"Teal Is Real","option3":null,"sku":"BC-BROTHER-CYCLES-KEPLER-FRAMESET-TEAL-IS-REAL-54CM","requires_shipping":true,"taxable":true,"featured_image":null,"available":true,"name":"Brother Cycles Kepler Frameset - 54cm \/ Teal Is Real","public_title":"54cm \/ Teal Is Real","options":["54cm","Teal Is Real"],"price":84900,"weight":3450,"compare_at_price":null,"inventory_management":"shopify","barcode":null,"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":57596177121663,"title":"56cm \/ Teal Is Real","option1":"56cm","option2":"Teal Is Real","option3":null,"sku":"BC-BROTHER-CYCLES-KEPLER-FRAMESET-TEAL-IS-REAL-56CM","requires_shipping":true,"taxable":true,"featured_image":null,"available":true,"name":"Brother Cycles Kepler Frameset - 56cm \/ Teal Is Real","public_title":"56cm \/ Teal Is Real","options":["56cm","Teal Is Real"],"price":84900,"weight":3450,"compare_at_price":null,"inventory_management":"shopify","barcode":null,"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":57596177154431,"title":"58cm \/ Teal Is Real","option1":"58cm","option2":"Teal Is Real","option3":null,"sku":"BC-BROTHER-CYCLES-KEPLER-FRAMESET-TEAL-IS-REAL-58CM","requires_shipping":true,"taxable":true,"featured_image":null,"available":false,"name":"Brother Cycles Kepler Frameset - 58cm \/ Teal Is Real","public_title":"58cm \/ Teal Is Real","options":["58cm","Teal Is Real"],"price":84900,"weight":3450,"compare_at_price":null,"inventory_management":"shopify","barcode":null,"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":57596177187199,"title":"60cm \/ Teal Is Real","option1":"60cm","option2":"Teal Is Real","option3":null,"sku":"BC-BROTHER-CYCLES-KEPLER-FRAMESET-TEAL-IS-REAL-60CM","requires_shipping":true,"taxable":true,"featured_image":null,"available":false,"name":"Brother Cycles Kepler Frameset - 60cm \/ Teal Is Real","public_title":"60cm \/ Teal Is Real","options":["60cm","Teal Is Real"],"price":84900,"weight":3450,"compare_at_price":null,"inventory_management":"shopify","barcode":null,"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}}],
templateName: 'product',
dataKey: 'top-strip-promotion-badge',
storefrontCurrency: 'GBP',
storefrontCountry: 'GB',
storefrontLanguage: 'en',
shopLocale: 'en',
shopDomain: 'projektride.co.uk',
variantPrice: '84900',
cartPrice: '0',
selector: 'shopify-osm-AZkxmY3VSTnFmNnNiW__klarna_on_site_messaging_app_block_k6rYHt',
topPadding: '0',
bottomPadding: '0',
});
} else {
window.appBlockPlacements.push({
productVariants: [{"id":57596176826751,"title":"50cm \/ Mellow Yellow","option1":"50cm","option2":"Mellow Yellow","option3":null,"sku":"BC-BROTHER-CYCLES-KEPLER-FRAMESET-MELLOW-YELLOW-50CM","requires_shipping":true,"taxable":true,"featured_image":null,"available":false,"name":"Brother Cycles Kepler Frameset - 50cm \/ Mellow Yellow","public_title":"50cm \/ Mellow Yellow","options":["50cm","Mellow Yellow"],"price":84900,"weight":3450,"compare_at_price":null,"inventory_management":"shopify","barcode":null,"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":57596176859519,"title":"52cm \/ Mellow Yellow","option1":"52cm","option2":"Mellow Yellow","option3":null,"sku":"BC-BROTHER-CYCLES-KEPLER-FRAMESET-MELLOW-YELLOW-52CM","requires_shipping":true,"taxable":true,"featured_image":null,"available":true,"name":"Brother Cycles Kepler Frameset - 52cm \/ Mellow Yellow","public_title":"52cm \/ Mellow Yellow","options":["52cm","Mellow Yellow"],"price":84900,"weight":3450,"compare_at_price":null,"inventory_management":"shopify","barcode":null,"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":57596176892287,"title":"54cm \/ Mellow Yellow","option1":"54cm","option2":"Mellow Yellow","option3":null,"sku":"BC-BROTHER-CYCLES-KEPLER-FRAMESET-MELLOW-YELLOW-54CM","requires_shipping":true,"taxable":true,"featured_image":null,"available":false,"name":"Brother Cycles Kepler Frameset - 54cm \/ Mellow Yellow","public_title":"54cm \/ Mellow Yellow","options":["54cm","Mellow Yellow"],"price":84900,"weight":3450,"compare_at_price":null,"inventory_management":"shopify","barcode":null,"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":57596176925055,"title":"56cm \/ Mellow Yellow","option1":"56cm","option2":"Mellow Yellow","option3":null,"sku":"BC-BROTHER-CYCLES-KEPLER-FRAMESET-MELLOW-YELLOW-56CM","requires_shipping":true,"taxable":true,"featured_image":null,"available":true,"name":"Brother Cycles Kepler Frameset - 56cm \/ Mellow Yellow","public_title":"56cm \/ Mellow Yellow","options":["56cm","Mellow Yellow"],"price":84900,"weight":3450,"compare_at_price":null,"inventory_management":"shopify","barcode":null,"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":57596176957823,"title":"58cm \/ Mellow Yellow","option1":"58cm","option2":"Mellow Yellow","option3":null,"sku":"BC-BROTHER-CYCLES-KEPLER-FRAMESET-MELLOW-YELLOW-58CM","requires_shipping":true,"taxable":true,"featured_image":null,"available":false,"name":"Brother Cycles Kepler Frameset - 58cm \/ Mellow Yellow","public_title":"58cm \/ Mellow Yellow","options":["58cm","Mellow Yellow"],"price":84900,"weight":3450,"compare_at_price":null,"inventory_management":"shopify","barcode":null,"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":57596176990591,"title":"60cm \/ Mellow Yellow","option1":"60cm","option2":"Mellow Yellow","option3":null,"sku":"BC-BROTHER-CYCLES-KEPLER-FRAMESET-MELLOW-YELLOW-60CM","requires_shipping":true,"taxable":true,"featured_image":null,"available":false,"name":"Brother Cycles Kepler Frameset - 60cm \/ Mellow Yellow","public_title":"60cm \/ Mellow Yellow","options":["60cm","Mellow Yellow"],"price":84900,"weight":3450,"compare_at_price":null,"inventory_management":"shopify","barcode":null,"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":57596177023359,"title":"50cm \/ Teal Is Real","option1":"50cm","option2":"Teal Is Real","option3":null,"sku":"BC-BROTHER-CYCLES-KEPLER-FRAMESET-TEAL-IS-REAL-50CM","requires_shipping":true,"taxable":true,"featured_image":null,"available":false,"name":"Brother Cycles Kepler Frameset - 50cm \/ Teal Is Real","public_title":"50cm \/ Teal Is Real","options":["50cm","Teal Is Real"],"price":84900,"weight":3450,"compare_at_price":null,"inventory_management":"shopify","barcode":null,"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":57596177056127,"title":"52cm \/ Teal Is Real","option1":"52cm","option2":"Teal Is Real","option3":null,"sku":"BC-BROTHER-CYCLES-KEPLER-FRAMESET-TEAL-IS-REAL-52CM","requires_shipping":true,"taxable":true,"featured_image":null,"available":true,"name":"Brother Cycles Kepler Frameset - 52cm \/ Teal Is Real","public_title":"52cm \/ Teal Is Real","options":["52cm","Teal Is Real"],"price":84900,"weight":3450,"compare_at_price":null,"inventory_management":"shopify","barcode":null,"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":57596177088895,"title":"54cm \/ Teal Is Real","option1":"54cm","option2":"Teal Is Real","option3":null,"sku":"BC-BROTHER-CYCLES-KEPLER-FRAMESET-TEAL-IS-REAL-54CM","requires_shipping":true,"taxable":true,"featured_image":null,"available":true,"name":"Brother Cycles Kepler Frameset - 54cm \/ Teal Is Real","public_title":"54cm \/ Teal Is Real","options":["54cm","Teal Is Real"],"price":84900,"weight":3450,"compare_at_price":null,"inventory_management":"shopify","barcode":null,"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":57596177121663,"title":"56cm \/ Teal Is Real","option1":"56cm","option2":"Teal Is Real","option3":null,"sku":"BC-BROTHER-CYCLES-KEPLER-FRAMESET-TEAL-IS-REAL-56CM","requires_shipping":true,"taxable":true,"featured_image":null,"available":true,"name":"Brother Cycles Kepler Frameset - 56cm \/ Teal Is Real","public_title":"56cm \/ Teal Is Real","options":["56cm","Teal Is Real"],"price":84900,"weight":3450,"compare_at_price":null,"inventory_management":"shopify","barcode":null,"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":57596177154431,"title":"58cm \/ Teal Is Real","option1":"58cm","option2":"Teal Is Real","option3":null,"sku":"BC-BROTHER-CYCLES-KEPLER-FRAMESET-TEAL-IS-REAL-58CM","requires_shipping":true,"taxable":true,"featured_image":null,"available":false,"name":"Brother Cycles Kepler Frameset - 58cm \/ Teal Is Real","public_title":"58cm \/ Teal Is Real","options":["58cm","Teal Is Real"],"price":84900,"weight":3450,"compare_at_price":null,"inventory_management":"shopify","barcode":null,"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":57596177187199,"title":"60cm \/ Teal Is Real","option1":"60cm","option2":"Teal Is Real","option3":null,"sku":"BC-BROTHER-CYCLES-KEPLER-FRAMESET-TEAL-IS-REAL-60CM","requires_shipping":true,"taxable":true,"featured_image":null,"available":false,"name":"Brother Cycles Kepler Frameset - 60cm \/ Teal Is Real","public_title":"60cm \/ Teal Is Real","options":["60cm","Teal Is Real"],"price":84900,"weight":3450,"compare_at_price":null,"inventory_management":"shopify","barcode":null,"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}}],
templateName: 'product',
shopLocale: 'en',
dataKey: 'top-strip-promotion-badge',
storefrontCurrency: 'GBP',
storefrontCountry: 'GB',
storefrontLanguage: 'en',
shopDomain: 'projektride.co.uk',
variantPrice: '84900',
cartPrice: '0',
selector: 'shopify-osm-AZkxmY3VSTnFmNnNiW__klarna_on_site_messaging_app_block_k6rYHt',
topPadding: '0',
bottomPadding: '0',
});
}
The Kepler is a versatile steel frame designed as a gravel grinder, commuter and tourer. It runs 700c or 650b wheels, clears 700c x 45 or 650b x 48 tyres, and is built from double-butted 4130 chromoly steel with ED coating. Features include a lugged steel fork with dynamo routing, internal rear brake cable routing, a brazed seat collar and full mounts for racks, mudguards and bottles.
}
return max;
}, '')
: null;
// Use cached if old array is empty/has no timestamps, or cached is newer
// Parse dates for comparison to handle format differences (+00:00 vs .000Z)
const cachedDate = new Date(cachedData.cached_at);
const maxDate = maxUpdatedAt ? new Date(maxUpdatedAt) : null;
const useCached = !maxUpdatedAt || (cachedDate && !isNaN(cachedDate) && (!maxDate || cachedDate > maxDate));
if (useCached) {
if (Array.isArray(cachedData.plans)) {
window._RestockRocketConfig.sellingPlans = cachedData.plans;
// Only use disabled_plan_ids when using cached plans
window._RestockRocketConfig.disabledSellingPlanIds = cachedData.disabled_plan_ids || [];
console.debug('[RR] Using selling plans from cachedSellingPlans (cached_at: ' + cachedData.cached_at + ')');
}
} else {
// When using old format (stale cache), don't trust disabled_plan
product = {"id":8724019314914,"title":"Restrap Pannier - Large","handle":"restrap-pannier-large","description":"\u003cp\u003e\u003cmeta charset=\"utf-8\"\u003e\u003cmeta charset=\"utf-8\"\u003e\u003cspan\u003eOur sleek roll-top panniers are designed for strength, stability and endurance. Available in small and large for both rear and front racks, they're fitted with side-release buckles and contain a fully adjustable hook system for easy mounting onto 10-16mm rails.\u003c\/span\u003e\u003cbr\u003e\u003cbr\u003e\u003cspan\u003eReflective detailing enhances your safety, whilst their 100% waterproof materials ensure their contents remain dry and secure. The large pannier also has space for a clip-in laptop sleeve. Check out the sleeve here.\u003c\/span\u003e\u003cbr\u003e\u003cbr\u003e\u003cspan\u003eHand made in our Yorkshire workshop, all bags are finished with the classic Restrap label, made from vegan-friendly PU.\u003c\/span\u003e\u003cbr\u003e\u003cbr\u003e\u003cspan\u003eSold as a single unit.\u003c\/span
What is your inside leg?How to measure: Stand barefoot with your back straight and against a wall. Tuck a ruler or something that extends to the floor between your legs. Using both hands, and keeping it level, pull the ruler up into your crotch as if you were sitting on the saddle. Measure the distance from the top edge of the ruler to the ground to find your inside leg measurement. Your inside leg is very important to your final bike size so please measure carefully.
age = Date.now() - updatedAt.getTime();
if (age
< SETTINGS_CACHE_DURATION) {
console.debug('STOQ - settings changed recently, skipping cache');
return null;
}
return settings;
} catch (error) {
console.debug('STOQ - Error checking settings cache:', error);
return null;
}
}
function createRestockRocketContainer() {
const restockRocketContainer = document.createElement('div');
restockRocketContainer.id = 'restock-rocket';
document.body.appendChild(restockRocketContainer);
}
function createRestockRocketScript(scriptUrl) {
const restockRocketScriptElement = document.createElement('script');
restockRocketScriptElement.setAttribute('defer', 'defer');
restockRocketScriptElement.src = scriptUrl;
document.body.appendChild(restockRocketScriptElement);
}
createRestockRocketContainer()
console.debug('STOQ - extension activated')
// Fire stoq_initialized once per page load so the funnel pipeline has a definitive
// "our code ran on this page" signal independent of any cus
tomer interaction.
// Detected variants: the variants present in this page's Liquid context (product page has them;
// collection/index/etc. don't expose variants from Liquid). Used to disambiguate "embed didn't
// load" vs "embed loaded but the variant wasn't a preorder/BIS candidate" in order debug.
try {
const _stoqInitConfig = window._RestockRocketConfig;
const _stoqDetectedVariantIds = (_stoqInitConfig.product && Array.isArray(_stoqInitConfig.product.variants))
? _stoqInitConfig.product.variants.map(function(v) { return v.id })
: [];
const _stoqSelectedVariantId = _stoqInitConfig.selected_variant_id;
Shopify?.analytics?.publish?.('stoq_initialized', {
cart_token: _stoqInitConfig.cartToken || '',
page_url: window.location.href,
page_type: _stoqInitConfig.pageType || '',
shop_domain: _stoqInitConfig.shop || '',
market_id: _stoqInitConfig.marketId || '',
detected_variant_ids: _stoqDetectedVariantIds,
selected_variant_id: _stoqSelectedVariantId || '',
liquid_rendered_at: _stoqInitConfig.liquidRenderedAt || 0,
app_version: _stoqInitConfig.appVersion || '',
liquid_cache_age: _stoqInitConfig.liquidCacheAge,
// Selected variant's stock posture as our app saw it at render — explains
// whether we *should* have treated it as a preorder candidate.
inventory_policy: (_stoqInitConfig.variantsInventoryPolicy || {})[_stoqSelectedVariantId] || '',
inventory_quantity: (_stoqInitConfig.variantsInventoryQuantity || {})[_stoqSelectedVariantId],
});
} catch (e) {
console.debug('STOQ - stoq_initialized publish failed:', e);
}
// STOQ-1595: publish stoq_accelerated_checkout_clicked for every accelerated-checkout
// click (Buy Now / dynamic checkout / Shop Pay installments) on ALL surfaces, before our
// bundle loads, via one delegated capture-phase listener (catches late-rendered buttons).
// Only on shops with preorders configured (shared `preordersConfigured` signal from the
// derivati
on block above) — nothing to bypass otherwise. variant_id is read per-clicked-button
// from its form so it's correct on collection/index/search too. block_accelerated_checkout
// context (STOQ-1612) rides in `properties` (forwarded verbatim by the pixel, no schema
// change): a buy_now click on a preorder variant while the gate was armed is a visible
// bypass signal for order debug. Also sends page_url (top-level, like the pixel's native
// events) and two preorder signals in properties (see below).
try {
var _sqTrack = window._RestockRocketConfig;
if (_sqTrack.preordersConfigured) {
document.addEventListener('click', function (e) {
try {
var t = e.target;
if (!t || !t.closest) return;
var host = t.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 || '';
// The enabled STOQ selling plan the clicked variant belongs to (if any), found once and
// reused for in_enabled_plan / enrolled_plan_id / enrolled_plan_provider below.
var _sqVidNum = Number(variantId);
var _sqPlan = null;
// Array.isArray guard (not `|| []`) so a truthy non-array sellingPlans can't throw and
// silently drop the whole publish.
var _sqPlans = Array.isArray(_sqTrack.sellingPlans) ? _sqTrack.sellingPlans : [];
_sqPlans.forEach(function (pl) {
if (!_sqPlan && pl && pl.enabled && Array.isArray(pl.variant_ids) &&
pl.variant_ids.indexOf(_sqVidNum) !== -1) { _sqPlan = pl; }
});
Shopify?.analytics?.publish?.('stoq_accelerated_checkout_clicked', {
variant_id: variantId,
product_id: (_sqTr
ack.product && _sqTrack.product.id) || '',
channel: channel,
market_id: _sqTrack.marketId || '',
page_type: _sqTrack.pageType || '',
cart_token: _sqTrack.cartToken || '',
page_url: (window.location && window.location.href) || '',
properties: {
// Mirror the bundle's own preorder check (preorder.js checkInventoryProvider-
// WithCachedFallback): the live set config.preorderVariantIds (refreshed after
// page load by loadVariantInventoryData) OR the Liquid-injected
// cachedPreorderVariantIds — always present, so it covers clicks before the
// bundle loads (why this tracker is inline). ORing both (not preferring one)
// matches the bundle and is correct even if the live set is an empty array. Both
// hold integer ids; the click-time id comes off a DOM input (.value → string) or
// selected_variant_id, so coerce with Number for
a like-typed compare.
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 &&
_sqTrack.cachedPreorderVariantIds.preorder_variant_ids);
})(),
// Narrow, authoritative preorder signal: enrolled in an ENABLED STOQ selling plan
// (is_preorder_variant above is the broad OOS+continue heuristic — non-STOQ too).
in_enabled_plan: !!_sqPlan,
// In-stock preorder signal: enrolled but currently IN STOCK (in the inStockVariantIds
// set, not the OOS preorderVariantIds set). Same live-OR-cached pattern as
// is_preorder_variant. is_preorder_variant OR is_instock_variant = "should sell via
// the plan" regardless of stock, so an in-stock preord
er bypass is detectable too.
is_instock_variant: (function () {
var has = function (a) { return Array.isArray(a) && a.indexOf(_sqVidNum) !== -1; };
return has(_sqTrack.inStockVariantIds) ||
has(_sqTrack.cachedInStockVariantIds &&
_sqTrack.cachedInStockVariantIds.in_stock_variant_ids);
})(),
// The enrolled plan's Shopify selling-plan id + inventory_provider (stoq = STOQ tracks
// the OOS count; shopify = in-stock preorder). Tells order-debug what kind of preorder
// the Buy Now bypassed, without a downstream lookup.
enrolled_plan_id: (_sqPlan && (_sqPlan.shopify_selling_plan_id || _sqPlan.shopify_selling_plan_group_id)) || '',
enrolled_plan_provider: (_sqPlan && _sqPlan.inventory_provider) || '',
block_enabled: !!(_sqTrack.cachedSettings && _sqTrack.cachedSettings.block_accelerated_checkout),
gate_armed: !!_sqTrack.acceleratedGateArmed,
gate_active_at_click: !!(document.documentElement &&
document.documentElement.classList.contains('stoq-buy-now-pending')),
},
});
} catch (err) { /* never break checkout */ }
}, true);
}
} catch (e) { /* fail open */ }
function applyTranslations(settings) {
try {
// Skip translation logic entirely if multi-language is not enabled
if (!settings || !settings.multi_language_enabled) {
return settings;
}
if (!settings.translations) {
console.debug('STOQ - No translations found, skipping translation');
return settings;
}
const normalizedLocale = window._RestockRocketConfig.normalizedLocale;
const translations = settings.translations;
if (!normalizedLocale) {
// No matching locale has translations; drop payload to save memory
console.debug('STOQ - No matching locale for translations. Available:', Object.keys(translations || {})
);
delete settings.translations;
return settings;
}
console.debug(`STOQ - Applying translations for normalized locale: ${normalizedLocale} (original: ${window._RestockRocketConfig.locale})`);
const translatedFields = translations[normalizedLocale];
if (translatedFields && typeof translatedFields === 'object') {
Object.keys(translatedFields).forEach(function(key) {
const value = translatedFields[key];
if (value !== null && value !== undefined && value !== '') {
settings[key] = value;
}
});
} else {
console.debug('STOQ - No translated fields found for locale:', normalizedLocale);
}
delete settings.translations;
return settings;
} catch (e) {
console.debug('STOQ - error applying translations:', e);
return settings;
}
}
// Setup event listener for cart selling plan updates
// This must be called before any scripts are loaded to avoid race conditions
func
tion setupCartSellingPlanUpdater(settings) {
// Setup listener regardless - updateCartSellingPlans has its own guards
// This ensures cleanup happens even when preorders are disabled globally
// Listen for stoq:inventory-data-loaded event dispatched by api.js
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);
});
}
});
}
// ---- Live settings via the Storefront API (additive, does not gate init) ----
// The inlined `cachedSettings` comes from the app-embed Liquid render, which
// Shopify edge-caches and can serve stale. Reading the same `settings` metafield
// back over the Storefront API is a POST to /api/<
version>/graphql.json — never
// CDN-cached — so it returns the live value on every page load. We fetch it
// best-effort and stash it on `window._RestockRocketConfig.storefrontSettings`
// so individual behaviours can migrate onto the fresh value over time. This is
// PURELY ADDITIVE: it does NOT change the resolution flow below, never blocks
// init, and silently no-ops on any failure / missing token.
(function loadStorefrontSettings() {
const cfg = window._RestockRocketConfig;
if (!cfg.storefrontAccessToken || cfg.disableStorefrontApi === true) return;
// Deferred to browser idle so this best-effort read runs strictly AFTER the
// critical init flow and never competes with it for a connection — the call
// is a live, uncached Storefront round-trip and can be slow (multi-second
// TTFB observed). Nothing on the critical path waits for it.
function run() {
const query = 'query StoqSettings($namespace: String!) { shop { metafield(namespace: $namespace, key: "settings") { value } } }';
fetch(
`https://${cfg.shop}/api/2025-07/graphql.json`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Shopify-Storefront-Access-Token': cfg.storefrontAccessToken,
},
body: JSON.stringify({ query: query, variables: { namespace: cfg.metafieldNamespace } }),
}
)
.then(function(response) {
if (!response.ok) { throw new Error('Storefront API HTTP ' + response.status); }
return response.json();
})
.then(function(body) {
if (body && body.errors && body.errors.length) {
throw new Error('Storefront API errors: ' + body.errors.map(function(e) { return e && e.message; }).join(', '));
}
const value = body && body.data && body.data.shop && body.data.shop.metafield && body.data.shop.metafield.value;
if (!value) { throw new Error('Storefront API returned no settings metafield value'); }
cfg.sto
refrontSettings = JSON.parse(value);
console.debug('STOQ - stored live settings from Storefront API on config.storefrontSettings');
})
.catch(function(e) {
console.debug('STOQ - Storefront settings fetch failed (non-fatal):', e && e.message);
});
}
if (typeof window.requestIdleCallback === 'function') {
window.requestIdleCallback(run, { timeout: 5000 });
} else {
setTimeout(run, 0);
}
})();
// First try to get settings from metafields with expiry check
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;
}
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 request failed and we have cached settings (even if expired), use them as fallback
if (cachedSettings) {
console.debug('STOQ - using expired cached settings as fallback');
initializeScripts(cachedSettings);
} else {
console.error('S
TOQ - failed to load settings:', error);
}
})
.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) {
// Apply failures are programming bugs (e.g. response shape changed
// server-side and the assignment threw). Surface them as console.error
// so they're visible in browser logs, then re-throw to fall through
// to the same Liquid-cached fallback as a fetch failure.
console.error('STOQ - apply failed for ' + endpoint + ':', applyError);
throw applyError;
}
})
.catch(function(error) {
console.debug(`STOQ - using cached ${endpoint}:`, error.message);
});
}
function initializeScripts(settings) {
settings = applyTranslations(settings);
window._RestockRocketConfig.settings = settings;
console.debug(`STOQ - settings configured for ${window._RestockRocketConfig.pageType}`);
// Stale-Liquid resilience (default-on, per-shop opt-out via the
// `disable_refresh_on_stale_liquid` Toggle, surfaced as the negative
// `disable_refresh_on_stale_liquid` flag in settings.json so that
// `undefined` -- in CDN-cached metafield payloads that predate this
// key -- reads as `!undefined === true` and gets default-on behavior
// immediately, no metafield rewrite required).
// When the Liquid CDN cache is older than LIQUID_CACHE_MAX_AGE the in-page
// selling_plans / integrations metafields can be wrong; refresh both from
// the API before launching scr
ipts. Race against a 1000ms timeout so a slow
// API can't block init indefinitely. If the timeout wins, the in-flight
// fetches still complete and update window._RestockRocketConfig — the
// bundle re-reads sellingPlans/integrations on every interaction, so the
// late-arriving values benefit subsequent renders even though the first
// paint may use the Liquid-cached values. On any failure the existing
// Liquid-loaded values stay in place via fetchEmbedConfig's catch.
if (!window._RestockRocketConfig.isLiquidCacheFresh && !settings.disable_refresh_on_stale_liquid) {
console.debug('STOQ - Liquid cache stale, refreshing selling_plans + integrations');
Promise.race([
Promise.all([
fetchEmbedConfig('selling_plans', function(data) {
if (data && Array.isArray(data.plans)) {
window._RestockRocketConfig.sellingPlans = data.plans;
window._RestockRocketConfig.disabledSellingPlanIds = data.disabled_plan_ids || [];
}
}),
fetchEmbedConfig('integrations', function(data) {
if (Array.isArray(data)) {
window._RestockRocketConfig.integrations = data;
}
})
]),
new Promise(function(resolve) { setTimeout(resolve, 1000); })
]).then(function() { loadScripts(settings); });
return;
}
loadScripts(settings);
}
function loadScripts(settings) {
// Setup cart selling plan updater BEFORE loading any scripts to avoid race conditions
setupCartSellingPlanUpdater(settings);
if(settings.enable_app) {
const hijackIntegration = window._RestockRocketConfig.integrations.find(function(integration) {
return integration.type === 'hijack' && integration.enabled && integration.page_types.includes(window._RestockRocketConfig.pageType);
})
// STOQ-1520: serve the lean back-in-stock-only build (no preorder/hijack code)
// only to shops with NO preorder plans. Use the full build if preorder is o
n,
// an enabled offer exists, or a disabled-but-kept plan id remains (cart sweep
// must still strip those). Rationale in the PR.
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 collectionScriptUrl = usePreorderBuild
? window._RestockRocketConfig.scriptUrlCollection
: window._RestockRocketConfig.scriptUrlCollectionBis;
const productScriptUrl = usePreorderBuild
? 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) {
// cart/article/blog/list-collections: full build so the cart sweep runs.
createRestockRocketScript(window._RestockRocketConfig.scriptUrlCollection);
} else {
console.debug(`STOQ - no scripts enabled for ${pageType}`);
}
// Dispatch custom event when app is loaded
// Cart selling plan updates will be triggered by stoq:inventory-data-loaded event
const appLoadedEvent = new CustomEvent('stoq:loaded', {
detail: {
pageType: window._RestockR
ocketConfig.pageType,
enabled: settings.enable_app,
settings: settings,
preorderEnabled: settings.preorder_enabled
}
});
console.debug('STOQ - dispatching app loaded event');
window.dispatchEvent(appLoadedEvent);
}
}