Amflow
window._RestockRocketConfig = window._RestockRocketConfig || {}
// Helper function to normalize locale format from hyphen to underscore (e.g., 'en-US' -> 'en_us')
// This matches the backend's Mobility.normalize_locale behavior
// Returns empty string if locale is empty or invalid (matches original behavior)
function normalizeLocale(locale) {
if (!locale || locale.trim() === '') {
return '';
}
return locale.toString().toLowerCase().replace(/-/g, '_');
}
window._RestockRocketConfig.locale = 'en';
window._RestockRocketConfig.normalizedLocale = normalizeLocale('en');
window._RestockRocketConfig.shop = 'projektride.myshopify.com';
window._RestockRocketConfig.pageType = 'collection';window._RestockRocketConfig.marketId = 382140642;window._RestockRocketConfig.countryName = 'United Kingdom';
window._RestockRocketConfig.countryIsoCode = 'GB';window._RestockRocketConfig.cartInventoryQuantity = {};window._RestockRocketConfig.cachedSettings = {"id":38500,"shop_id":38436,"currency":"GBP","created_at":"2025-07-26T09:13:57.337Z","updated_at":"2025-11-11T14:27:02.312Z","enable_app":true,"enable_signup_widget":false,"storefront_button_text":"Notify me when available","storefront_button_text_color":"#FFFFFF","storefront_button_background_color":"#202223","storefront_form_header":"Notify me","storefront_form_description":"Get a notification as soon as this product is back in stock by signing up below!","storefront_form_button_text":"Notify me when available","storefront_form_button_text_color":"#FFFFFF","storefront_form_button_background_color":"#202223","storefront_form_terms":"Promise we won't spam. You'll only receive notifications for this product.","storefront_form_error":"Please enter a valid email address","storefront_form_success":"Thank you! We will notify you when the product is available.","enable_powered_by":true,"show_button_on_preorder":true,"sms_enabled":false,"email_enabled":true,"storefront_button_disable_tag":"rocket-hide","theme_config":{},"storefront_form_email_placeholder":"Email address","storefront_form_phone_placeholder":"SMS","storefront_form_phone_label":"Phone number","storefront_form_email_label":"Email","storefront_form_phone_error":"Please enter a valid phone number","storefront_form_customer_name_placeholder":"Name","storefront_form_customer_name_error":"Please enter your name","storefront_form_did_you_mean_error":"Did you mea
down_timer_ends_text":null,"updated_at":"2025-08-19T10:05:43.042Z","allow_mixed_cart":true}];window._RestockRocketConfig.integrations = [{"id":"15c94526-b6b8-4de1-9bc1-23b1ca52ddb0","shop_id":38436,"enabled":true,"page_types":["product","collection","index","search","page","cart","list-collections","article","blog"],"configuration":{"toastDuration":10000,"toastPosition":"bottom-right","enableXHRHijack":true,"enableFetchHijack":true,"quantityLimitDisabled":false},"type":"hijack","css_config":null,"js_config":null,"created_at":"2025-07-26T09:16:04.076Z","updated_at":"2025-07-26T09:16:04.076Z"}];window._RestockRocketConfig.obfuscateInventoryQuantity = false;window._RestockRocketConfig.scriptUrlProduct = 'https://cdn.shopify.com/extensions/019ade57-efc1-7a93-a1b4-30689b78f362/restock-rocket-shopify-401/assets/restockrocket-product.js'
window._RestockRocketConfig.scriptUrlCollection = 'https://cdn.shopify.com/extensions/019ade57-efc1-7a93-a1b4-30689b78f362/restock-rocket-shopify-401/assets/restockrocket-collecti
on.js'
window._RestockRocketConfig.scriptHost = window._RestockRocketConfig.scriptUrlProduct.substring(0, window._RestockRocketConfig.scriptUrlProduct.lastIndexOf('/') + 1)
window._RestockRocketConfig.host = 'https://app.restockrocket.io'
const SETTINGS_CACHE_DURATION = 15 * 60 * 1000; // 15 minutes in milliseconds
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;
}
// Check if translations are enabled but missing from cache
// This handles the backfill period where DB has translations but metafield doesn't
if (settings.multi_language_enabled) {
if (!settings.translations) {
// Translations enabled but no translation data in metafield
// Metafield hasn't been backfilled yet - force refresh
console.debug('STOQ - multi-language enabled but no translation data in cache, fetching fresh');
return null;
}
// Translations object exists in metafield - cache is valid
// If current locale isn't translated, applyTranslations will gracefully use default locale from base fields
if (window._RestockRocketConfig.normalizedLocale &&
!Object.prototype.hasOwnProperty.call(settings.translations, window._RestockRocketConfig.normalizedLocale)) {
console.debug('STOQ - locale not explicitly translated, will use default language from cache');
}
// Don't return null - continue using cache even for untranslated locales
}
const updatedAt = new Date(settings.updated_at);
if (isNaN(updatedAt.getTime())) {
console.debug('STOQ - Invalid updated_at date format in settings');
return null;
}
const age = Date.now() - updatedAt.getTime();
if (age Brother< 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')
function applyTranslations(settings) {
try {
// Skip translation logic entirely if multi-language is not enabled
if (!settings ||
!settings.multi_language_enabled) {
return