The OneUp bar profile minimizes the length of the 35 diameter clamping area as this is the stiffest portior.n of any 35 diameter bar. The 35mm clamp diameter quickly changes to a flattened, oval shape in the transition zone and then to a standard 22.2mm clamp diameter for the control zone.
The OneUp Dropper post is now available in
120mm, 150mm, 180mm and 210mm lengths
{"@context":"http:\/\/schema.org\/","@id":"\/products\/one-up-components-carbon-handlebars#product","@type":"ProductGroup","brand":{"@type":"Brand","name":"One-Up"},"category":"","description":"\nCARBON HANDLEBAR\n\n\n\nONEUP CARBON BARS. Strong, lightweight \u0026amp; vertically compliant.\n\n\n\n\nThe goal for the new OneUp Carbon Handlebars was to make the best feeling bar possible, something that would let us ride harder for longer.The solution is our patent pending oval shape which combines the best ride characteristics of 31.8mm and 35mm bar standards into one package. This is the most comfortable bar we’ve ever ridden, period. It's strong, lightweight minimizes arm pump and vibration and maximizes steering response. 35 done right.\n\n\n\n\n\"The OneUp bar gives me all of the confidence inspiring attributes of a 35mm bar with a bit of forgiveness engineered in for those big descents. I've been so impressed after putting it through the paces for the last year.\" —Thomas Vanderham\n\nAlmost every other carbon bar on the market copies the simple tapered profile of an Aluminum bar. With carbon you can take advantage of more complex shapes to get a better performing product, so that's what we did. If you actually care about bar compliance, then you don't make a regular 35mm diameter bar. Sure you can try to \"optimize\" the flex slightly with layup, but geometry is king and you're fighting a losing battle.The OneUp bar profile minimizes the length of the 35 diameter clamping area as this is the stiffest portior.n of any 35 diameter bar. The 35mm clamp diameter quickly changes to a flattened, oval shape in the transition zone and then to a standard 22.2mm clamp diameter for the control zone.\n \nWe bench marked the OneUp bar against the most popular carbon bars on the market as well as foam filled aluminum bars. The results were, on average, a 21% increase in vertical compliance (comfort) coupled with a 28% increase in steering stiffness (responsiveness). These are more than just marginal gains.\n\n\nUntil now the 35mm diameter standard has had a bad reputation and rightly so. This is 35 Dia. done right.\n\n\n\n\n\n\n\nSPECS \n\nGeometry: 800mm Wide \/ 35mm Dia. \/ Sweep 8° Back 5° Up \n\nWeight: 20mm Rise (220g) 35mm Rise (225g)\n\n\nMax Stem Clamp Width: 65mm\n\n\nMax Stem Clamp Torque: 6Nm\nMax Lever Clamp Torque: 5Nm\n\nMinimum Trim width: 740mm\nColour: Black. Decal kits: Available in Red, Green, Blue, Orange, Purple \u0026amp; White\n\nCOMPATIBILITY\nGrips with only an outer clamp are not compatible with our bar.\n","hasVariant":[{"@id":"\/products\/one-up-components-carbon-handlebars?variant=42157868581090#variant","@type":"Product","image":"https:\/\/projektride.co.uk\/cdn\/shop\/products\/OneUp-Components-Carbon-Handlebar-35mm-Rise-Front-Black-966_grande_2a2952ec-89a2-4bf1-bcd1-f64bbdb1b8f1.jpg?v=1639501128\u0026width=1920","name":"One-Up Components Carbon Handlebars - 20mm Rise","offers":{"@id":"\/products\/one-up-components-carbon-handlebars?variant=42157868581090#offer","@type":"Offer","availability":"http:\/\/schema.org\/InStock","price":"126.00","priceCurrency":"GBP","url":"https:\/\/projektride.co.uk\/products\/one-up-components-carbon-handlebars?variant=42157868581090"},"sku":"1C0459"},{"@id":"\/products\/one-up-components-carbon-handlebars?variant=42157868613858#variant","@type":"Product","image":"https:\/\/projektride.co.uk\/cdn\/shop\/products\/OneUp-Components-Carbon-Handlebar-35mm-Rise-Front-Black-966_grande_2a2952ec-89a2-4bf1-bcd1-f64bbdb1b8f1.jpg?v=1639501128\u0026width=1920","name":"One-Up Components Carbon Handlebars - 35mm Rise","offers":{"@id":"\/products\/one-up-components-carbon-handlebars?variant=42157868613858#offer","@type":"Offer","availability":"http:\/\/schema.org\/InStock","price":"126.00","priceCurrency":"GBP","url":"https:\/\/projektride.co.uk\/products\/one-up-components-carbon-handlebars?variant=42157868613858"},"sku":"1C0585"}],"name":"One-Up Components Carbon Handlebars","productGroupID":"7473345069282","url":"https:\/\/projektride.co.uk\/products\/one-up-components-carbon-handlebars"}
and all can be shimmed down in travel by 10 or 20mm. #Accordions--template--26482384994687__section_accordions_with_images_kprcYa {
--PT: 60px;
--PB: 60px;
--border-opacity: 0;
--border-width: 1px;
--MB: 10px;
--padding-left: 0;
--bg-padded-line: var(--bg);
}
#Accordions--template--26482384994687__section_accordions_with_images_kprcYa .section__heading { --heading-size: calc(var(--adjust-heading) * 1.2); }
#Accordions--template--26482384994687__section_accordions_with_images_kprcYa .accordion__item { --bg-item: #fafafa; }
We've been obsessed with shaving every last millimeter from the latest OneUp post to give you the the
shortest stack height
and
shortest total length
Frequently Asked Questions
of any dropper post. No other post can get your saddle lower.
22.2mm Bar Clamp
- All other groups 10 speed SHIMANO
Cable clamping remote only (post requires cable stop to be assembled at base of post)
Travel Reducing Shim
Reduces travel by up to 20mm.
Patented
drop r
ail c
lamp (
10,370,051)
other patents pending
Please get in touch with a member of the team either by phone (
01313745324
) or email (Refund policy[email protected]
) where on of the team will be more than happy to help.
ProjektRide Bike Shop Edinburgh
Service
Servicing
If the item is showing in stock, we aim to post the product within 24 hours. Please allow 5 working days to receive the item.
Postage is free on orders over £50. Orders under £50, our postage charge is £3.99.Book a Service
We also have a physical store, if you are local please pop in -
\u003c\/strong\u003e 6Nm\u003c\/span\u003e\u003c\/div\u003e\n\u003cdiv data-mce-fragment=\"1\"\u003e\u003cspan data-mce-fragment=\"1\"\u003e\u003cb data-mce-fragment=\"1\"\u003eMax Lever Clamp Torque\u003c\/b\u003e: 5Nm\u003c\/span\u003e\u003c\/div\u003e\n\u003c\/div\u003e\n\u003cdiv data-mce-fragment=\"1\"\u003e\u003cspan data-mce-fragment=\"1\"\u003e\u003cstrong data-mce-fragment=\"1\"\u003eMinimum Trim width\u003c\/strong\u003e: 740mm\u003c\/span\u003e\u003c\/div\u003e\n\u003cstrong data-mce-fragment=\"1\"\u003eColour\u003c\/strong\u003e: Black. Decal kits: Available in Red, Green, Blue, Orange, Purple \u0026amp; White\u003c\/div\u003e\n\u003cp data-mce-fragment=\"1\"\u003e\u003cbr data-mce-fragment=\"1\"\u003e\u003c\/p\u003e\n\u003ch3 data-mce-fragment=\"1\"\u003eCOMPATIBILITY\u003c\/h3\u003e\n\u003cp data-mce-fragment=\"1\"\u003eGrips with only an outer clamp are not compatible with our bar.\u003c\/p\u003e\n\u003c\/div\u003e","published_at":"2025-01-04T10:41:20+00:00","created_at":"2021-12-14T16:58:4
6+00:00","vendor":"One-Up","type":"","tags":["Handlebars","spo-cs-disabled","spo-default","spo-disabled","spo-notify-me-disabled"],"price":12600,"price_min":12600,"price_max":12600,"available":true,"price_varies":false,"compare_at_price":12600,"compare_at_price_min":12600,"compare_at_price_max":12600,"compare_at_price_varies":false,"variants":[{"id":42157868581090,"title":"20mm Rise","option1":"20mm Rise","option2":null,"option3":null,"sku":"1C0459","requires_shipping":true,"taxable":true,"featured_image":null,"available":true,"name":"One-Up Components Carbon Handlebars - 20mm Rise","public_title":"20mm Rise","options":["20mm Rise"],"price":12600,"weight":1000,"compare_at_price":12600,"inventory_management":"shopify","barcode":"","requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":42157868613858,"title":"35mm Rise","option1":"35mm Rise","option2":null,"option3":null,"sku":"1C0585","requires_shipping":true,"taxable":true,"featured_image":null,"available":true,"name":"One-Up Components Carbon Handlebars - 35mm Rise","public_title":"35mm Rise","options":["35mm Rise"],"price":12600,"weight":1000,"compare_at_price":12600,"inventory_management":"shopify","barcode":"","requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}}],"images":["\/\/projektride.co.uk\/cdn\/shop\/products\/OneUp-Components-Carbon-Handlebar-35mm-Rise-Front-Black-966_grande_2a2952ec-89a2-4bf1-bcd1-f64bbdb1b8f1.jpg?v=1639501128","\/\/projektride.co.uk\/cdn\/shop\/products\/OneUp-Components-Carbon-Handlebar-20mm-Rise-Black-966.jpg?v=1639501128","\/\/projektride.co.uk\/cdn\/shop\/products\/OneUp-Components-Bar-20mm-Rise-EDC-Stem-50mm-Sp.original.jpg?v=1639501128"],"featured_image":"\/\/projektride.co.uk\/cdn\/shop\/products\/OneUp-Components-Carbon-Handlebar-35mm-Rise-Front-Black-966_grande_2a2952ec-89a2-4bf1-bcd1-f64bbdb1b8f1.jpg?v=1639501128","options":["Size"],"media":[{"alt":null,"id":28842522804450,"position":1,"preview_image":{
"aspect_ratio":1.0,"height":600,"width":600,"src":"\/\/projektride.co.uk\/cdn\/shop\/products\/OneUp-Components-Carbon-Handlebar-35mm-Rise-Front-Black-966_grande_2a2952ec-89a2-4bf1-bcd1-f64bbdb1b8f1.jpg?v=1639501128"},"aspect_ratio":1.0,"height":600,"media_type":"image","src":"\/\/projektride.co.uk\/cdn\/shop\/products\/OneUp-Components-Carbon-Handlebar-35mm-Rise-Front-Black-966_grande_2a2952ec-89a2-4bf1-bcd1-f64bbdb1b8f1.jpg?v=1639501128","width":600},{"alt":null,"id":28842522837218,"position":2,"preview_image":{"aspect_ratio":1.0,"height":966,"width":966,"src":"\/\/projektride.co.uk\/cdn\/shop\/products\/OneUp-Components-Carbon-Handlebar-20mm-Rise-Black-966.jpg?v=1639501128"},"aspect_ratio":1.0,"height":966,"media_type":"image","src":"\/\/projektride.co.uk\/cdn\/shop\/products\/OneUp-Components-Carbon-Handlebar-20mm-Rise-Black-966.jpg?v=1639501128","width":966},{"alt":null,"id":28842522869986,"position":3,"preview_image":{"aspect_ratio":1.501,"height":1066,"width":1600,"src":"\/\/projektride.co.uk\/cdn\/shop\/products\/OneUp-Components-Bar-20mm-Rise-EDC-Stem-50mm-Sp.original.jpg?v=1639501128"},"aspect_ratio":1.501,"height":1066,"media_type":"image","src":"\/\/projektride.co.uk\/cdn\/shop\/products\/OneUp-Components-Bar-20mm-Rise-EDC-Stem-50mm-Sp.original.jpg?v=1639501128","width":1600}],"requires_selling_plan":false,"selling_plan_groups":[],"content":"\u003cmeta charset=\"utf-8\"\u003e\n\u003ch1 class=\"product_name\" data-mce-fragment=\"1\" itemprop=\"name\"\u003eCARBON HANDLEBAR\u003c\/h1\u003e\n\u003cdiv class=\"yotpo bottomLine yotpo-small\" data-product-id=\"4461162692743\" data-yotpo-element-id=\"2\" data-mce-fragment=\"1\"\u003e\n\u003cdiv class=\"yotpo-display-wrapper\" data-mce-fragment=\"1\"\u003e\n\u003cdiv class=\"yotpo-clr\" data-mce-fragment=\"1\"\u003e\n\u003cstrong data-mce-fragment=\"1\"\u003eONEUP CARBON BARS. Strong, lightweight \u0026amp; vertically compliant.\u003c\/strong\u003e\u003cbr\u003e\n\u003c\/div\u003e\n\u003c\/div\u003e\n\u003c\/div\u003e\n\u003cdiv class=\"description\" data-mce-
fragment=\"1\" itemprop=\"description\"\u003e\n\u003cbr data-mce-fragment=\"1\"\u003eThe goal for the new OneUp Carbon Handlebars was to make the best feeling bar possible, something that would let us ride harder for longer.\u003cbr data-mce-fragment=\"1\"\u003e\u003cbr data-mce-fragment=\"1\"\u003e\u003cspan data-mce-fragment=\"1\"\u003eThe solution is our patent pending oval shape which combines the best ride characteristics of 31.8mm and 35mm bar standards into one package. This is the most comfortable bar we’ve ever ridden, period. It's strong, lightweight minimizes arm pump and vibration and maximizes steering response. 35 done right.\u003c\/span\u003e\n\u003cblockquote data-mce-fragment=\"1\"\u003e\n\u003ch5 class=\"a-section a-spacing-small\" data-mce-fragment=\"1\"\u003e\n\u003cspan data-mce-fragment=\"1\"\u003e\u003c\/span\u003e\u003cbr data-mce-fragment=\"1\"\u003e\n\u003c\/h5\u003e\n\u003cem data-mce-fragment=\"1\"\u003e\"The OneUp bar gives me all of the confidence inspiring attributes of a 35mm bar with a bit of forgiveness engineered in for those big descents. I've been so impressed after putting it through the paces for the last year.\" \u003c\/em\u003e\u003cspan class=\"quotes-author-large\" data-mce-fragment=\"1\"\u003e\u003cstrong data-mce-fragment=\"1\"\u003e\u003cspan class=\"quotes-author-dash\" data-mce-fragment=\"1\"\u003e—\u003c\/span\u003eThomas Vanderham\u003c\/strong\u003e\u003c\/span\u003e\n\u003c\/blockquote\u003e\n\u003cspan data-mce-fragment=\"1\"\u003eAlmost every other carbon bar on the market copies the simple tapered profile of an Aluminum bar. With carbon you can take advantage of more complex shapes to get a better performing product, so that's what we did. If you actually care about bar compliance, then you don't make a regular 35mm diameter bar. Sure you can try to \"optimize\" the flex slightly with layup, but geometry is king and you're fighting a losing battle.\u003c\/span\u003e\u003cbr data-mce-fragment=\"1\"\u003e\u003cbr data-mce-fragment=\"1\"\u003eThe OneUp
bar profile minimizes the length of the 35 diameter clamping area as this is the stiffest portior.n of any 35 diameter bar. The 35mm clamp diameter quickly changes to a flattened, oval shape in the transition zone and then to a standard 22.2mm clamp diameter for the control zone.\n\u003cp data-mce-fragment=\"1\"\u003e \u003c\/p\u003e\n\u003cspan data-mce-fragment=\"1\"\u003eWe bench marked the OneUp bar against the most popular carbon bars on the market as well as foam filled aluminum bars. The results were, on average, a 21% increase in vertical compliance (comfort) coupled with a 28% increase in steering stiffness (responsiveness). These are more than just marginal gains.\u003c\/span\u003e\n\u003cdiv data-feature-name=\"productDescription\" data-template-name=\"productDescription\" class=\"a-row feature\" data-mce-fragment=\"1\"\u003e\u003cbr data-mce-fragment=\"1\"\u003e\u003c\/div\u003e\n\u003cdiv data-feature-name=\"productDescription\" data-template-name=\"productDescription\" class=\"a-row feature\"
data-mce-fragment=\"1\"\u003e\n\u003cbr data-mce-fragment=\"1\"\u003e\u003cspan data-mce-fragment=\"1\"\u003eUntil now the 35mm diameter standard has had a bad reputation and rightly so. This is 35 Dia. done right.\u003c\/span\u003e\n\u003c\/div\u003e\n\u003cdiv data-feature-name=\"productDescription\" data-template-name=\"productDescription\" class=\"a-row feature\" data-mce-fragment=\"1\"\u003e\n\u003cspan data-mce-fragment=\"1\"\u003e\u003c\/span\u003e\u003cbr data-mce-fragment=\"1\"\u003e\n\u003c\/div\u003e\n\u003cdiv data-feature-name=\"productDescription\" data-template-name=\"productDescription\" class=\"a-row feature\" data-mce-fragment=\"1\"\u003e\u003cbr data-mce-fragment=\"1\"\u003e\u003c\/div\u003e\n\u003ch3 dir=\"ltr\" data-mce-fragment=\"1\"\u003e\u003cbr data-mce-fragment=\"1\"\u003e\u003c\/h3\u003e\n\u003ch3 data-mce-fragment=\"1\"\u003e\n\u003cspan data-mce-fragment=\"1\"\u003eSPECS\u003c\/span\u003e \u003c\/h3\u003e\n\u003cdiv data-mce-fragment=\"1\"\u003e\n\u003cstrong data-mce-fragmen
t=\"1\"\u003eGeometry:\u003c\/strong\u003e\u003cspan data-mce-fragment=\"1\"\u003e \u003c\/span\u003e800mm Wide \/ 35mm Dia. \/ Sweep 8° Back 5° Up \u003c\/div\u003e\n\u003cdiv data-mce-fragment=\"1\"\u003e\n\u003cb data-mce-fragment=\"1\"\u003eWeight\u003c\/b\u003e: 20mm Rise (220g) 35mm Rise (225g)\u003c\/div\u003e\n\u003cdiv data-mce-fragment=\"1\"\u003e\n\u003cdiv data-mce-fragment=\"1\"\u003e\n\u003cb data-mce-fragment=\"1\"\u003eMax Stem Clamp Width\u003c\/b\u003e\u003cspan data-mce-fragment=\"1\"\u003e: 65mm\u003c\/span\u003e\n\u003c\/div\u003e\n\u003cdiv data-mce-fragment=\"1\"\u003e\n\u003cdiv data-mce-fragment=\"1\"\u003e\u003cspan data-mce-fragment=\"1\"\u003e\u003cstrong data-mce-fragment=\"1\"\u003eMax Stem Clamp Torque:\u003c\/strong\u003e 6Nm\u003c\/span\u003e\u003c\/div\u003e\n\u003cdiv data-mce-fragment=\"1\"\u003e\u003cspan data-mce-fragment=\"1\"\u003e\u003cb data-mce-fragment=\"1\"\u003eMax Lever Clamp Torque\u003c\/b\u003e: 5Nm\u003c\/span\u003e\u003c\/div\u003e\n\u003c\/div\u003e\n\u003cdiv data-mce-fragment=\"1\"\u003e\u003cspan data-mce-fragment=\"1\"\u003e\u003cstrong data-mce-fragment=\"1\"\u003eMinimum Trim width\u003c\/strong\u003e: 740mm\u003c\/span\u003e\u003c\/div\u003e\n\u003cstrong data-mce-fragment=\"1\"\u003eColour\u003c\/strong\u003e: Black. Decal kits: Available in Red, Green, Blue, Orange, Purple \u0026amp; White\u003c\/div\u003e\n\u003cp data-mce-fragment=\"1\"\u003e\u003cbr data-mce-fragment=\"1\"\u003e\u003c\/p\u003e\n\u003ch3 data-mce-fragment=\"1\"\u003eCOMPATIBILITY\u003c\/h3\u003e\n\u003cp data-mce-fragment=\"1\"\u003eGrips with only an outer clamp are not compatible with our bar.\u003c\/p\u003e\n\u003c\/div\u003e"};
window._RestockRocketConfig.variantsInventoryPolicy = {42157868581090 : "deny",42157868613858 : "deny",};
window._RestockRocketConfig.variantsInventoryQuantity = {42157868581090 : parseInt("70"),42157868613858 : parseInt("100"),};
window._RestockRocketConfig.variantsPreorderCount = {42157868581090 : parseInt(""),42157868613858 : pa
rseInt(""),};
window._RestockRocketConfig.variantsPreorderCountForMarket = {42157868581090 : null,42157868613858 : null,};
window._RestockRocketConfig.variantsPreorderMaxCount = {42157868581090 : parseInt(""),42157868613858 : parseInt(""),};
window._RestockRocketConfig.variantsPreorderMaxCountForMarket = {42157868581090 : null,42157868613858 : null,};
window._RestockRocketConfig.variantsShippingText = {42157868581090 : "",42157868613858 : "",};
window._RestockRocketConfig.variantsShippingTextForMarket = {42157868581090 : null,42157868613858 : null,};
window._RestockRocketConfig.selected_variant_id = 42157868581090;
window._RestockRocketConfig.selected_variant_available = window._RestockRocketConfig.product.variants.find(function(variant) { return variant.id == window._RestockRocketConfig.selected_variant_id }).available;window._RestockRocketConfig.scriptUrlProduct = 'https://cdn.shopify.com/extensions/019d9ac9-5dee-74e9-8643-e17aaa8798db/restockrocket-1-482/assets/restockrocket-pro
duct.js'
window._RestockRocketConfig.scriptUrlCollection = 'https://cdn.shopify.com/extensions/019d9ac9-5dee-74e9-8643-e17aaa8798db/restockrocket-1-482/assets/restockrocket-collection.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
const LIQUID_CACHE_MAX_AGE = 2 * 60 * 60; // 2 hours in seconds
// Calculate Liquid cache freshness once at initialization
const liquidRenderedAt = window._RestockRocketConfig.liquidRenderedAt;
// Validate timestamp and calculate cache age
if (!liquidRenderedAt || typeof liquidRenderedAt !== 'number' || isNaN(liquidRenderedAt)) {
console.debug('STOQ - Invalid or missing liquidRenderedAt timestamp, assuming fresh');
window._RestockRocketConfig.isLiquidCacheFresh = true;
} else {
const no
w = Math.floor(Date.now() / 1000); // Current time in seconds
const liquidCacheAge = now - liquidRenderedAt; // Age in seconds
// Handle client clock ahead of server
if (liquidCacheAge <
0) {
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 <
= 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;
}
// 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
<
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 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
function 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);
});
}
});
}
// 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.S
hopify.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(cac