PageSourceSearch

https://oblist.com/cdn/shop/t/140/assets/shopify-price-sync.js?v=172158282328329543791785939943

js oblist.com collected 2026-09-28 12:51:58 UTC 7,534 bytes, 2 lines download raw bytes

1(function(){"use strict";const STOREFRONT_API_VERSION="2024-01",PRICE_CACHE=new Map,PRODUCT_CACHE=new Map,DEBOUNCE_MS=500;let debounceTimer=null;function getVariantDefaultConfig(){return window.__OBLIST_VARIANT_DEFAULT__||{enabled:!0,fromPrefix:"From"}}function isCheapestDefaultEnabled(){return getVariantDefaultConfig().enabled!==!1}function getConfig(){return window.__SHOPIFY_STOREFRONT__||{}}function getShopifyRoot(){try{if(window.Shopify&&window.Shopify.routes&&typeof window.Shopify.routes.root=="string")return window.Shopify.routes.root}catch{}return"/"}function getStorefrontUrl(){return`${getShopifyRoot()}api/${STOREFRONT_API_VERSION}/graphql.json`}function formatPrice(amount,currencyCode){const price=Math.round(parseFloat(amount));switch(currencyCode){case"USD":return`$${price}`;case"GBP":return`\xA3${price}`;case"ILS":return`\u20AA${price}`;case"RUB":return`\u20BD${price}`;default:return`${price}\u20AC`}}function hasTradePriceOverlay(salePriceEl){const text=(salePriceEl.textContent||"").toLowerCase();return text.indexOf("trade price")!==-1||text.indexOf("prix trade")!==-1}function getPurchasablePool(product){if(!product||!product.variants||!product.variants.length)return[];const available=product.variants.filter(v=>v.available);return available.length?available:product.variants}function getEntryVariant(product){const pool=getPurchasablePool(product);return pool.length?isCheapestDefaultEnabled()?pool.reduce((min,v)=>v.price<min.price?v:min):pool.find(v=>v.available)||pool[0]:null}function priceVariesInPool(product){const pool=getPurchasablePool(product);if(pool.length<=1)return!1;let min=pool[0].price,max=pool[0].price;for(let i=1;i<pool.length;i++)pool[i].price<min&&(min=pool[i].price),pool[i].price>max&&(max=pool[i].price);return min!==max}function formatCardPrice(amount,currencyCode,priceVaries){const formatted=formatPrice(amount,currencyCode);return!priceVaries||!isCheapestDefaultEnabled()?formatted:`${getVariantDefaultConfig().fromPrefix||"From"} ${formatted}`}function setCardPrice(card,formatted){const salePriceEl=card.querySelector("sale-price");if(!salePriceEl)return!1;if(hasTradePriceOverlay(salePriceEl))return salePriceEl.classList.remove("price--loading"),!1;const srOnly=salePriceEl.querySelector(".sr-only");let currentText=salePriceEl.textContent||"";return srOnly&&srOnly.textContent&&(currentText=currentText.replace(srOnly.textContent,"")),currentText=currentText.replace(/\s+/g," ").trim(),currentText===formatted?(salePriceEl.classList.remove("price--loading"),!1):(salePriceEl.textContent="",srOnly&&salePriceEl.appendChild(srOnly),salePriceEl.appendChild(document.createTextNode(formatted)),salePriceEl.classList.remove("price--loading"),!0)}function fetchProduct(handle){if(PRODUCT_CACHE.has(handle))return PRODUCT_CACHE.get(handle);const promise=fetch(`${getShopifyRoot()}products/${encodeURIComponent(handle)}.js`).then(res=>res.ok?res.json():null).catch(()=>null);return PRODUCT_CACHE.set(handle,promise),promise}async function alignCardsToEntryVariant(cards){let aligned=0;await Promise.all(cards.map(async card=>{const handle=card.getAttribute("handle");if(!handle)return;const product=await fetchProduct(handle);if(!product||!product.variants||!product.variants.length)return;const entryVariant=getEntryVariant(product);if(!entryVariant)return;var currencyCode="EUR";try{window.Shopify&&window.Shopify.currency&&window.Shopify.currency.active&&(currencyCode=window.Shopify.currency.active)}catch{}const varies=priceVariesInPool(product),priceData={amount:Number(entryVariant.price)/100,currencyCode,priceVaries:varies};card.setAttribute("data-variant-id",String(entryVariant.id)),card.setAttribute("data-price-varies",varies?"true":"false"),PRICE_CACHE.set(String(entryVariant.id),priceData),PRICE_CACHE.set(handle,priceData),setCardPrice(card,formatCardPrice(priceData.amount,priceData.currencyCode,varies))&&aligned++})),aligned>0&&console.log(`[Storefront Prices] Aligned ${aligned} cards to entry variant (${isCheapestDefaultEnabled()?"cheapest":"first"} available)`)}function buildNodesQuery(variantIds){const country=getConfig().country||"FR",gids=variantIds.map(id=>`"gid://shopify/ProductVariant/${id}"`).join(", ");return`query @inContext(country: ${country}) { nodes(ids: [${gids}]) { ... on ProductVariant { id price { amount currencyCode } product { handle } } } }`}async function fetchBatch(variantIds){const cfg=getConfig();if(!cfg.token)return{};const query=buildNodesQuery(variantIds);try{const response=await fetch(getStorefrontUrl(),{method:"POST",headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":cfg.token},body:JSON.stringify({query})});if(!response.ok)return{};const data=await response.json();if(!data.data||!data.data.nodes)return{};const prices={};
1return data.data.nodes.forEach(node=>{if(!node||!node.price||!node.product)return;const variantId=node.id.replace("gid://shopify/ProductVariant/",""),handle=node.product.handle,priceData={amount:node.price.amount,currencyCode:node.price.currencyCode};prices[variantId]=priceData,prices[handle]=priceData,PRICE_CACHE.set(variantId,priceData),PRICE_CACHE.set(handle,priceData)}),prices}catch(e){return console.warn("[Storefront Prices] Fetch error:",e),{}}}function updateDOMPrices(prices){let updated=0;document.querySelectorAll("product-card[handle], .bridge-card[handle], .sold-out-alternatives__card[data-variant-id], #similar-pieces-seed[handle]").forEach(card=>{const handle=card.getAttribute("handle"),variantId=card.getAttribute("data-variant-id"),priceData=variantId&&prices[variantId]||prices[handle]||PRICE_CACHE.get(variantId)||PRICE_CACHE.get(handle);if(!priceData)return;const varies=priceData.priceVaries===!0||card.getAttribute("data-price-varies")==="true";setCardPrice(card,formatCardPrice(priceData.amount,priceData.currencyCode,varies))&&updated++}),updated>0&&console.log(`[Storefront Prices] Updated ${updated} product prices`)}async function syncPrices(){try{const allCards=Array.prototype.slice.call(document.querySelectorAll("product-card[handle], .bridge-card[handle], .sold-out-alternatives__card[data-variant-id], #similar-pieces-seed[handle]"));if(allCards.length===0)return;await alignCardsToEntryVariant(allCards.filter(function(card){return card.getAttribute("handle")}));const variantIds=[];if(allCards.forEach(function(card){const variantId=card.getAttribute("data-variant-id");variantId&&!PRICE_CACHE.has(variantId)&&variantIds.push(variantId)}),variantIds.length===0){updateDOMPrices({});return}let allPrices={};for(let i=0;i<variantIds.length;i+=50){const batch=variantIds.slice(i,i+50),fetched=await fetchBatch(batch);Object.assign(allPrices,fetched)}updateDOMPrices(allPrices)}catch(e){console.warn("[Storefront Prices] Sync error:",e)}finally{revealAllPrices()}}function revealAllPrices(){const nodes=document.querySelectorAll("sale-price.price--loading");for(let i=0;i<nodes.length;i++)nodes[i].classList.remove("price--loading")}function syncVisible(){const fallbackTimer=setTimeout(revealAllPrices,3e3),done=syncPrices();done&&typeof done.then=="function"?done.then(function(){clearTimeout(fallbackTimer)},function(){clearTimeout(fallbackTimer)}):clearTimeout(fallbackTimer)}function debouncedSync(){debounceTimer&&clearTimeout(debounceTimer),debounceTimer=setTimeout(function(){syncPrices()},DEBOUNCE_MS)}window.ShopifyPriceSync={sync:syncPrices,syncVisible,debouncedSync,formatPrice,getCache:()=>PRICE_CACHE}})();
2//# sourceMappingURL=/cdn/shop/t/140/assets/shopify-price-sync.js.map?v=172158282328329543791785939943

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.