1(function(){"use strict";async function updateExistingCartItems(){try{const cart=await(await fetch("/cart.js",{cache:"no-store",headers:{"Cache-Control":"no-cache"}})).json();if(!cart.items||cart.items.length===0)return;const itemsNeedingUpdate=cart.items.filter(function(item){return!item.properties||!item.properties._volume_price_breaks});if(itemsNeedingUpdate.length===0){console.log("[B2B Volume Discount] All cart items have catalog tiers");return}console.log("[B2B Volume Discount] "+itemsNeedingUpdate.length+" items need catalog tier update");const variantB2BData=new Map;await Promise.all(itemsNeedingUpdate.map(async function(item){const data=await fetchVariantB2BData(item.handle,item.variant_id);data&&variantB2BData.set(item.variant_id,data)}));const updates={};let hasUpdates=!1;for(let i=0;i<itemsNeedingUpdate.length;i++){const item=itemsNeedingUpdate[i],b2bData=variantB2BData.get(item.variant_id);if(!b2bData){console.log("[B2B Volume Discount] No B2B catalog data for variant "+item.variant_id);continue}if(!b2bData.volumePriceBreaks){console.log("[B2B Volume Discount] No volume tiers in catalog for variant "+item.variant_id);continue}const newProperties=Object.assign({},item.properties||{},{_parent_product_id:b2bData.productId,_volume_price_breaks:b2bData.volumePriceBreaks});updates[item.key]={quantity:item.quantity,properties:newProperties},hasUpdates=!0,console.log("[B2B Volume Discount] Will update variant "+item.variant_id+" with catalog tiers:",b2bData.volumePriceBreaks)}if(!hasUpdates){console.log("[B2B Volume Discount] No catalog tier updates needed");return}await updateCartItems(updates),console.log("[B2B Volume Discount] Successfully updated cart with B2B catalog tiers"),await refreshCart()}catch(error){console.error("[B2B Volume Discount] Failed to update cart items:",error)}}async function fetchVariantB2BData(handle,variantId){try{const html=await(await fetch("/products/"+handle+"?variant="+variantId+"&_="+Date.now(),{cache:"no-store"})).text(),doc=new DOMParser().parseFromString(html,"text/html"),productIdInput=doc.querySelector('input[name="properties[_parent_product_id]"]'),volumeBreaksInput=doc.querySelector('input[name="properties[_volume_price_breaks]"]');return console.log("[B2B Volume Discount] Fetched variant "+variantId+":",{hasProductId:!!(productIdInput&&productIdInput.value),hasVolumeBreaks:!!(volumeBreaksInput&&volumeBreaksInput.value),volumeBreaks:volumeBreaksInput&&volumeBreaksInput.value||"none"}),!productIdInput||!productIdInput.value?null:{productId:productIdInput.value,volumePriceBreaks:volumeBreaksInput&&volumeBreaksInput.value||null}}catch(error){return console.error("[B2B Volume Discount] Failed to fetch B2B data for "+handle+":",error),null}}async function updateCartItems(updates){const keys=Object.keys(updates);for(let i=0;i<keys.length;i++){const lineKey=keys[i],updateData=updates[lineKey];await fetch("/cart/change.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:lineKey,quantity:updateData.quantity,properties:updateData.properties})})}}async function refreshCart(){try{const cart=await(await fetch("/cart.js",{cache:"no-store"})).json();window.Cart&&window.Cart.data&&(window.Cart.data=cart);for(var cartEvents=["cart:refresh","cart:updated","theme:cart:refresh","cart:change"],i=0;i<cartEvents.length;i++)document.dispatchEvent(new CustomEvent(cartEvents[i],{bubbles:!0,detail:{cart}}));window.dispatchEvent(new CustomEvent("cart:refresh",{detail:{cart}})),await refreshCartSections(),console.log("[B2B Volume Discount] Cart refreshed")}catch(error){console.error("[B2B Volume Discount] Failed to refresh cart:",error),window.location.reload()}}async function refreshCartSections(){try{var sectionIds=["cart-drawer","cart-items","cart-icon-bubble","cart-icon","header","mini-cart","cart-notification","cart-form"].join(","),response=await fetch("/?sections="+sectionIds,{cache:"no-store"});if(!response.ok)return;var sections=await response.json();for(var sectionId in sections)if(sections.hasOwnProperty(sectionId)){var html=sections[sectionId],sectionElement=document.getElementById("shopify-section-"+sectionId);if(sectionElement&&typeof html=="string"){var tempDiv=document.createElement("div");tempDiv.innerHTML=html;var newSection=tempDiv.firstElementChild;newSection&&(sectionElement.innerHTML=newSection.innerHTML)}}}catch(error){console.log("[B2B Volume Discount] Section refresh skipped:",error)}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",updateExistingCartItems):updateExistingCartItems()})(); 2//# sourceMappingURL=/cdn/shop/t/832/assets/b2b-volume-discount.js.map?v=158343244339370250281790818202
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.