$
2
- '+tagsLi+'
select size
'; } document .getElementById('sizeGuideButtonText') .addEventListener( 'click', trackEventSizeChartTextClick, ); } // set size drop-down let selectSizeButton = document.getElementById( 'selectSizeButtonDiv', ); let firstSize = false && currentColorVariationProduct.useNormalizedSizes && window?.bestOfferSizeVariationClientSide?.normalizedSize ? window?.bestOfferSizeVariationClientSide?.normalizedSize :window?.bestOfferSizeVariationClientSide?.size; const expList0 = [{"id":45,"saved_date":"2025-04-10T13:23:02.000Z","modified_date":"2025-05-06T14:00:21.000Z","config":"{\"variations\":[{\"allocation\":\"50\",\"name\":\"original\"},{\"allocation\":\"50\",\"name\":\"Variation 1\"}],\"expGroupId\":\"5279043307304970|2711371141125923\",\"traffic\":\"100\"}","name":"NODE_MIGRATION_VERSION","google_exp_id":"ED_SS_EXP_45","wild_card":"","status":"active","page_type":"[\"product_page\"]","priority":0,"campaign_name":"^$|^null$|organicshopping","variationsDistribution":[{"allocation":"50","name":"original","bucketKey":0,"bucket":{"min":1,"max":50}},{"allocation":"50","name":"Variation 1","bucketKey":1,"bucket":{"min":51,"max":100}}],"configTemp":{"variations":[{"allocation":"50","name":"original","bucketKey":0,"bucket":{"min":1,"max":50}},{"allocation":"50","name":"Variation 1","bucketKey":1,"bucket":{"min":51,"max":100}}],"expGroupId":"5279043307304970|2711371141125923","traffic":"100"},"behaviour":0,"trafficAllocation":{"5279043307304970":{"min":1,"max":100},"2711371141125923":{"min":1,"max":100}},"applicable":true},{"id":20,"saved_date":"2024-05-16T10:33:29.000Z","modified_date":"2024-08-28T09:01:39.000Z","config":"{\"variations\":[{\"allocation\":\"0\",\"name\":\"original\"},{\"allocation\":\"100\",\"name\":\"Variation 1\"},{\"allocation\":\"0\",\"name\":\"Variation 2\"},{\"allocation\":\"0\",\"name\":\"Variation 3\"}]}","name":"CATALOG_PAGE_UI_PRODUCT_PAGE","google_exp_id":"VWO_SS_55","wild_card":"","status":"active","page_type":"[\"product_page\"]","priority":10,"campaign_name":null,"variationsDistribution":[{"allocation":"0","name":"original","bucketKey":0,"bucket":false},{"allocation":"100","name":"Variation 1","bucketKey":1,"bucket":{"min":1,"max":100}},{"allocation":"0","name":"Variation 2","bucketKey":2,"bucket":false},{"allocation":"0","name":"Variation 3","bucketKey":3,"bucket":false}],"configTemp":{"variations":[{"allocation":"0","name":"original","bucketKey":0,"bucket":false},{"allocation":"100","name":"Variation 1","bucketKey":1,"bucket":{"min":1,"max":100}},{"allocation":"0","name":"Variation 2","bucketKey":2,"bucket":false},{"allocation":"0","name":"Variation 3","bucketKey":3,"bucket":false}]},"behaviour":1,"applicable":false},{"id":38,"saved_date":"2024-10-24T09:57:26.000Z","modified_date":"2024-11-22T05:13:01.000Z","config":"{\"variations\":[{\"allocation\":\"100\",\"name\":\"original\"},{\"allocation\":\"0\",\"name\":\"Variation 1\",\"featureFlags\":[\"NORMALISATION\"]}]}","name":"NORMALIZATION","google_exp_id":"ED_SS_EXP_28","wild_card":"","status":"active","page_type":"[\"product_page\"]","priority":11,"campaign_name":"organicshopping","variationsDistribution":[{"allocation":"100","name":"original","bucketKey":0,"bucket":{"min":1,"max":100}},{"allocation":"0","name":"Variation 1","featureFlags":["NORMALISATION"],"bucketKey":1,"bucket":false}],"configTemp":{"variations":[{"allocation":"100","name":"original","bucketKey":0,"bucket":{"min":1,"max":100}},{"allocation":"0","name":"Variation 1","featureFlags":["NORMALISATION"],"bucketKey":1,"bucket":false}]},"behaviour":0,"applicable":false}]; if(window.normalizedSizeFromUrl){ firstSize = window.normalizedSizeFromUrl; } else if(window.sizeFromUrl){ firstSize = window.sizeFromUrl; } function trackCheckoutButtonClicked() { window.nativeCheckoutButtonClick = true; document .getElementById('nativeCheckoutButtonID') .removeEventListener('click', trackCheckoutButtonClicked); } function trackSizeDropDownClicked() { window.sizeDropDownClickedSet = true; selectSizeButton .removeEventListener('click', trackSizeDropDownClicked); } if(toHideDropdown){ const dropDownDiv = document.querySelector('.dropdown-container-main'); if(dropDownDiv){ dropDownDiv.remove(); window.toHideDropdown = true; } } else if (selectSizeButton && firstSize && !toHideDropdown) { if(window.bestOfferSizeVariationClientSide.inStock){ if(!checkoutTemplate && (0 === 1 || 0 === 1)) { selectSizeButton.innerHTML = ''; } else { selectSizeButton.innerHTML = ''; } } else { if(!checkoutTemplate && (0 === 1 || 0 === 1)) { selectSizeButton.innerHTML = ''; } else { selectSizeButton.innerHTML = ''; } window.oosSizeSelectedOnClient = true; } window.selectSizeButtonIDSet = true; selectSizeButton = document.getElementById( 'selectSizeButtonDiv', ); selectSizeButton.addEventListener( 'click', trackSizeDropDownClicked, ); } const numberFormat = function numberFormat(number, decimals, decPoint, thousandsSep) { const tempNumber = String(number).replace(/[^0-9+\-Ee.]/g, ""); const n = !Number.isFinite(+tempNumber) ? 0 : +tempNumber; const prec = !Number.isFinite(+decimals) ? 0 : Math.abs(decimals); const sep = typeof thousandsSep === "undefined" ? "," : thousandsSep; const dec = typeof decPoint === "undefined" ? "." : decPoint; let s = ""; const toFixedFix = function temp(tn, precc) { if (`${tn}`.indexOf("e") === -1) { return +`${Math.round(`${tn}e+${precc}`)}e-${precc}`; } const arr = `${tn}`.split("e"); let sig = ""; if (+arr[1] + precc > 0) { sig = "+"; } return (+`${Math.round(`${+arr[0]}e${sig}${+arr[1] + precc}`)}e-${precc}`).toFixed(precc); }; // @todo: for IE parseFloat(0.55).toFixed(0) = 0; s = (prec ? toFixedFix(n, prec).toString() : `${Math.round(n)}`).split("."); if (s[0].length > 3) { s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep); } if ((s[1] || "").length < prec) { s[1] = s[1] || ""; s[1] += new Array(prec - s[1].length + 1).join("0"); } return s.join(dec);} // price to be set from here const price = window?.bestOfferSizeVariationClientSide?.salePrice; const compareAtPrice = window?.bestOfferSizeVariationClientSide?.regularPrice; const discount = calculatePercentageDifference( compareAtPrice, price, ); const priceDiv = document.getElementById('productMainPrice'); if (compareAtPrice && compareAtPrice>price && priceDiv) { priceDiv.innerHTML = '$' + numberFormat(compareAtPrice, 0, '.', ',') + ' $' + numberFormat(price, 0, '.', ',') + ' (' + discount + '% off)
'; window.checkoutPriceSetThroughScript = true; } else if(priceDiv) { priceDiv.innerHTML = '$' + numberFormat(price, 0, '.', ',') + ''; window.checkoutPriceSetThroughScript = true; } } else { isCheckoutNativeError = 'Native Checkout - product page: No inventory : '; } } else{ isCheckoutNativeError = 'Native Checkout - product page: variationID data not present : '; } } if ("30308451" && false) { const currentUrl = window.location.href; const controller = new AbortController(); const signal = controller.signal; const timeout = 5000; const timeoutId = setTimeout(() => { // Abort the fetch request if it's taking too long controller.abort(); }, timeout); const variationId = "30308451~spill the tea" const variationIdArr = ["30308451~spill the tea","30308451~dark cocoa","30308451~baddest beige","30308451~truth or bare","30308451~pinky swear","30308451~mauve aside","30308451~red receipt","30308451~plum & get it"]; let addedQueryParams = {}; try { addedQueryParams = {} } catch (error) { } const fetchProductAttributesBody = { source: ["productKeyId","variationId","sizeVariations","customTags","brandName","regularPrice","salePrice","externalUrl","externalLink","visible","color","imagesUrls","mlImagesUrls","mlColorGroup","colorGroupMl","colorGroup","discount","inStock","isFinalSale","expectedShippingDate","priceHistoryData","checkoutType","shippingReturnInfo","maxPrice","minPrice","currentPrice","sizes","slug","searchable","productLines","collections","collectionIds","llmDescription","displaySizes","enquiry","shippingAndReturnInformation","brandSlug","name","cleanName","editorNote","affiliate","categoryIds","retailerId","retailerName","description","hsl5GroupingKey","hsl10GroupingKey","colorGroupingKey"], productKeys: variationIdArr, feTraceId: '58e78dd7-1555-4a84-b71f-76b99426563d', ...addedQueryParams } if(false){ fetchProductAttributesBody.useNormalizedProductSizes = true; } const rawObj = { method: 'POST', headers: { 'Content-Type': 'application/json', 'client-trace-id': window.clientTraceId ?? '', 'server-trace-id': window.serverTraceId ?? '', }, signal, body: JSON.stringify(fetchProductAttributesBody), } const apiName = 'fetchProductAttributes'; const api = '/_nextjs/api/fetchProductAttributes/'; fetch(api, rawObj) .then(response => { if (signal.aborted) { if (window.clarity !== undefined) { window.clarity( 'set', 'Native Checkout - product page - '+apiName+' API Aborted due to timeout', ); } throw new Error('Native Checkout - product page - '+apiName+' API Aborted due to timeout: '); } return response.json(); }) .then(json => { var checkoutApiResponse = {}; if (json.result) { if(!(json.result && json.result.productDetails && json.result.productDetails.length)){ isCheckoutNativeError = 'Native Checkout - product page: '+apiName+' No products : '; } else{ for (let i = 0; i < json.result.productDetails.length; i += 1) { checkoutApiResponse[json.result.productDetails[i].variationId] = json.result.productDetails[i]; } } let bestOfferVariationId = "30308451~spill the tea"; // if normalization experiment is applied // finding bestOffer productId size const productP1 = checkoutApiResponse[variationId]; if(productP1){ let bestOfferSizeVariation = productP1.sizeVariations.filter( el => el.bestOffer === true, )?.[0] ?? productP1.sizeVariations?.filter( el => el.inStock === true, )?.[0] ?? {}; const queryParams = new URLSearchParams(window.location.search); const sizeFromUrl = queryParams.get('size'); const normalizedSizeFromUrl = queryParams.get('size'); const sizeInVariation = productP1.sizeVariations.find( el => el.size?.toLowerCase() === sizeFromUrl?.toLowerCase(), ); const normalizedSizeInVariation = productP1.sizeVariations.find( el => el.normalizedSize?.toLowerCase() === normalizedSizeFromUrl?.toLowerCase() ); const givenSizePresentInVariation = sizeFromUrl && sizeInVariation; const givenNormalizedSizePresentInVariation = normalizedSizeFromUrl && normalizedSizeInVariation && productP1.useNormalizedSizes && false; if (normalizedSizeFromUrl && givenNormalizedSizePresentInVariation){ bestOfferSizeVariation = normalizedSizeInVariation window.normalizedSizeFromUrl = normalizedSizeInVariation.normalizedSize; } else if (sizeFromUrl && givenSizePresentInVariation) { bestOfferSizeVariation = sizeInVariation; window.sizeFromUrl = sizeInVariation.size; } if(false ){ window.checkoutApiResponse = checkoutApiResponse; } else if(false){ bestOfferVariationId = bestOfferSizeVariation.productKey; // getting all data related to all different product keys let productKeyArr = [...variationIdArr]; for (let i = 0; i < json.result.productDetails.length; i += 1) { const elem = json.result.productDetails[i]; for(let j=0; j