PageSourceSearch

https://www.partycity.com/cdn/shop/t/25/assets/headless-cart-creat…?v=121884195076895959621790178034

js partycity.com collected 2026-10-02 02:52:42 UTC 8,529 bytes, 2 lines download raw bytes

1(function(){"use strict";var CONFIG={storefrontAccessToken:window.storefrontAccessToken,apiVersion:"2026-01",countryCode:"US"},isRedirecting=!1;function getApiUrl(){return"https://"+window.Shopify.shop+"/api/"+CONFIG.apiVersion+"/graphql.json"}var CART_CREATE_MUTATION="mutation cartCreate($input: CartInput) { cartCreate(input: $input) { cart { id } userErrors { field message } } }";function storefrontFetch(query,variables){var headers={"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":CONFIG.storefrontAccessToken};return fetch(getApiUrl(),{method:"POST",headers:headers,body:JSON.stringify({query:query,variables:variables})}).then(function(res){return res.json()})}function getNativeCart(){return fetch("/cart.js").then(function(res){return res.json()})}function mapDeliveryMethod(selectedMethod){if(!selectedMethod)return null;var m=selectedMethod.toLowerCase().trim();return m==="delivery"||m==="shipping"?["SHIPPING"]:m==="pickup"?["PICK_UP"]:null}function resolveInflations(selectedMethod,props,cartAttributes){var attrs=cartAttributes||{};if(selectedMethod==="shipping")return null;if(selectedMethod==="delivery"){var pcProductType=typeof props._pcProductType=="string"?props._pcProductType.trim():"",heliumDisabled=attrs.heliumdisabled,pcHeliumNeeded=typeof props._pcHeliumNeeded=="string"?props._pcHeliumNeeded.trim():"";return pcProductType==="true"&&(heliumDisabled===!1||heliumDisabled==="false")&&pcHeliumNeeded==="true"?"Helium-Filled":null}if(selectedMethod==="pickup"){var pcProductType=typeof props._pcProductType=="string"?props._pcProductType.trim():"",heliumDisabled=attrs.heliumdisabled,airDisabled=attrs.airdisabled,pcHeliumNeeded=typeof props._pcHeliumNeeded=="string"?props._pcHeliumNeeded.trim():"",pcNitrogenNeeded=typeof props._pcNitrogenNeeded=="string"?props._pcNitrogenNeeded.trim():"";if(pcProductType!=="true")return null;var heliumOk=heliumDisabled===!1||heliumDisabled==="false",airOk=airDisabled===!1||airDisabled==="false",manualSelection=typeof props.inflations=="string"?props.inflations.trim():"";return manualSelection==="Helium-Filled"&&heliumOk?"Helium-Filled":manualSelection==="Air-Filled"&&airOk?"Air-Filled":manualSelection==="Uninflated"?"Uninflated":heliumOk&&pcHeliumNeeded==="true"?"Helium-Filled":airOk&&pcNitrogenNeeded==="true"?"Air-Filled":"Uninflated"}return null}function buildLines(items,selectedMethod,cartAttributes){return items.map(function(item){var props=item.properties||{},rawPreOrder=typeof props._preOrder=="string"?props._preOrder.trim():"",rawTemplateSuffix=typeof props._templateSuffix=="string"?props._templateSuffix.trim():"",preOrder,templateSuffix;selectedMethod==="shipping"&&rawTemplateSuffix==="pre-order"?(preOrder="true",templateSuffix="pre-order"):(preOrder="false",templateSuffix=rawTemplateSuffix.length>0?rawTemplateSuffix:"");var inflationsValue=resolveInflations(selectedMethod,props,cartAttributes),cleanProps={};if(Object.keys(props).forEach(function(k){k!=="_preOrder"&&k!=="_templateSuffix"&&k!=="Pre-Order"&&k!=="inflations"&&(cleanProps[k]=props[k])}),cleanProps._preOrder=preOrder,cleanProps._templateSuffix=templateSuffix,inflationsValue!==null&&(cleanProps.inflations=inflationsValue),selectedMethod==="shipping"){var dateRange=typeof props._originalPreOrderExpectedDateRange=="string"?props._originalPreOrderExpectedDateRange.trim():"";dateRange.length>0&&(cleanProps["Pre-Order"]="Expected In-Stock "+dateRange)}var line={merchandiseId:"gid://shopify/ProductVariant/"+item.variant_id,quantity:item.quantity,attributes:Object.keys(cleanProps).map(function(k){return{key:k,value:String(cleanProps[k])}})};return item.selling_plan_allocation&&item.selling_plan_allocation.selling_plan&&(line.sellingPlanId="gid://shopify/SellingPlan/"+item.selling_plan_allocation.selling_plan.id),line})}function buildAttributes(cartAttributes){return cartAttributes?Object.keys(cartAttributes).map(function(k){return{key:k,value:String(cartAttributes[k])}}):[]}function getDiscountCodes(nativeCart){return!nativeCart.discount_codes||!Array.isArray(nativeCart.discount_codes)||nativeCart.discount_codes.length===0?[]:nativeCart.discount_codes.filter(function(d){return d.code}).map(function(d){return d.code})}function getGiftCardCodes(nativeCart){if(!nativeCart.attributes||!nativeCart.attributes.gift_card_codes)return[];var raw=nativeCart.attributes.gift_card_codes;try{var parsed=JSON.parse(raw);
1if(Array.isArray(parsed))return parsed.filter(Boolean)}catch(e){return raw.split(",").map(function(c){return c.trim()}).filter(Boolean)}return[]}function buildCartInput(nativeCart,deliveryMethod,selectedMethod){var deliveryPreference={deliveryMethod:deliveryMethod};deliveryMethod[0]==="PICK_UP"&&nativeCart.attributes&&nativeCart.attributes.locationID&&(deliveryPreference.pickupHandle=[String(nativeCart.attributes.locationID)]);var input={lines:buildLines(nativeCart.items,selectedMethod,nativeCart.attributes),attributes:buildAttributes(nativeCart.attributes),buyerIdentity:{countryCode:CONFIG.countryCode,preferences:{delivery:deliveryPreference}}};deliveryMethod[0]==="SHIPPING"&&nativeCart.attributes&&nativeCart.attributes.zipcode&&(input.delivery={addresses:[{selected:!0,address:{deliveryAddress:{zip:String(nativeCart.attributes.zipcode),countryCode:CONFIG.countryCode}}}]}),nativeCart.note&&(input.note=nativeCart.note);var discounts=getDiscountCodes(nativeCart);discounts.length>0&&(input.discountCodes=discounts);var giftCards=getGiftCardCodes(nativeCart);giftCards.length>0&&(input.giftCardCodes=giftCards);var customerToken=window.customerAccessToken||null;return customerToken&&(input.buyerIdentity.customerAccessToken=customerToken),input}function setCartCookie(token){var cookieParts=["cart="+token,"path=/","max-age=2592000","SameSite=Lax"];window.location.protocol==="https:"&&cookieParts.push("Secure"),document.cookie=cookieParts.join("; ")}var DMS_SS_KEY="dms_preselect";function ssGet(){try{return JSON.parse(sessionStorage.getItem(DMS_SS_KEY)||"null")}catch(e){return null}}function getLocationKey(selectedMethod,attributes){return attributes?selectedMethod==="pickup"?attributes.franchise_name||null:selectedMethod==="delivery"&&attributes.storeID||null:null}function ssSet(method,nativeToken,headlessToken,locationKey){try{sessionStorage.setItem(DMS_SS_KEY,JSON.stringify({method:method,native:nativeToken,headless:headlessToken,locationKey:locationKey||null}))}catch(e){}}function isDmsUpToDate(selectedMethod,nativeCartToken,locationKey){var d=ssGet();return!d||d.method!==selectedMethod||!d.headless||d.locationKey!==locationKey?!1:d.native===nativeCartToken||d.headless===nativeCartToken}function showSpinner(){var spinner=document.querySelector("#bodyLoader");spinner&&spinner.classList.remove("hidden")}function hideSpinner(){if(!isRedirecting){var spinner=document.querySelector("#bodyLoader");spinner&&spinner.classList.add("hidden")}}document.addEventListener("DOMContentLoaded",function(){window.location.pathname==="/cart"&&(showSpinner(),setTimeout(function(){getNativeCart().then(function(nativeCart){var selectedMethod=nativeCart.attributes&&nativeCart.attributes.selected_method?nativeCart.attributes.selected_method:null;if(!selectedMethod){hideSpinner();return}if(!nativeCart.items||nativeCart.items.length===0){hideSpinner();return}var locationKey=getLocationKey(selectedMethod,nativeCart.attributes);if(isDmsUpToDate(selectedMethod,nativeCart.token,locationKey)){var headlessToken=ssGet().headless;setCartCookie(headlessToken);var cookieGuard=setInterval(function(){setCartCookie(headlessToken)},500);window.addEventListener("beforeunload",function(){clearInterval(cookieGuard)}),hideSpinner();return}var deliveryMethod=mapDeliveryMethod(selectedMethod);if(!deliveryMethod){hideSpinner();return}return storefrontFetch(CART_CREATE_MUTATION,{input:buildCartInput(nativeCart,deliveryMethod,selectedMethod)}).then(function(json){if(!json){hideSpinner();return}if(json.errors||json.data.cartCreate.userErrors.length>0){hideSpinner();return}var token=json.data.cartCreate.cart.id.replace("gid://shopify/Cart/","");if(token){isRedirecting=!0,ssSet(selectedMethod,nativeCart.token,token,locationKey),setCartCookie(token);var preReloadGuard=setInterval(function(){setCartCookie(token)},500);window.addEventListener("beforeunload",function(){clearInterval(preReloadGuard)}),window.location.reload(!0)}else hideSpinner()})}).catch(function(){hideSpinner()})},4e3))})})();
2//# sourceMappingURL=/cdn/shop/t/25/assets/headless-cart-create-with-preselect.js.map?v=121884195076895959621790178034

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.