1(function(){'use strict';var globalPriceFormat={requiredPrecision:2,integerRequired:1,decimalSymbol:',',groupSymbol:',',groupLength:','};function stringPad(string,times){return(new Array(times+1)).join(string);} 2function formatPriceLocale(amount,format,isShowSign){var s='',precision,pattern,locale,r;format=_.extend(globalPriceFormat,format);precision=isNaN(format.requiredPrecision=Math.abs(format.requiredPrecision))?2:format.requiredPrecision;pattern=format.pattern||'%s';locale=window.LOCALE||'en-US';if(isShowSign===undefined||isShowSign===true){s=amount<0?'-':isShowSign?'+':'';}else if(isShowSign===false){s='';} 3pattern=pattern.indexOf('{sign}')<0?s+pattern:pattern.replace('{sign}',s);amount=Number(Math.round(Math.abs(+amount||0)+'e+'+precision)+('e-'+precision));r=amount.toLocaleString(locale,{minimumFractionDigits:precision});return pattern.replace('%s',r).replace(/^\s\s*/,'').replace(/\s\s*$/,'');} 4function formatPrice(amount,format,isShowSign){var s='',precision,integerRequired,decimalSymbol,groupSymbol,groupLength,pattern,i,pad,j,re,r,am;format=_.extend(globalPriceFormat,format);precision=isNaN(format.requiredPrecision=Math.abs(format.requiredPrecision))?2:format.requiredPrecision;integerRequired=isNaN(format.integerRequired=Math.abs(format.integerRequired))?1:format.integerRequired;decimalSymbol=format.decimalSymbol===undefined?',':format.decimalSymbol;groupSymbol=format.groupSymbol===undefined?'.':format.groupSymbol;groupLength=format.groupLength===undefined?3:format.groupLength;pattern=format.pattern||'%s';if(isShowSign===undefined||isShowSign===true){s=amount<0?'-':isShowSign?'+':'';}else if(isShowSign===false){s='';} 5pattern=pattern.indexOf('{sign}')<0?s+pattern:pattern.replace('{sign}',s);i=parseInt(amount=Number(Math.round(Math.abs(+amount||0)+'e+'+precision)+('e-'+precision)),10)+'';pad=i.length<integerRequired?integerRequired-i.length:0;i=stringPad('0',pad)+i;j=i.length>groupLength?i.length%groupLength:0;re=new RegExp('(\\d{'+groupLength+'})(?=\\d)','g');am=Number(Math.round(Math.abs(amount-i)+'e+'+precision)+('e-'+precision));r=(j?i.substr(0,j)+groupSymbol:'')+ 6i.substr(j).replace(re,'$1'+groupSymbol)+ 7(precision?decimalSymbol+am.toFixed(precision).replace(/-/,0).slice(2):'');return pattern.replace('%s',r).replace(/^\s\s*/,'').replace(/\s\s*$/,'');} 8function objectDeepClone(obj){return JSON.parse(JSON.stringify(obj));} 9function findOptionId(element){var re,id,name;if(!element){return id;} 10name=$(element).attr('name');if(name.indexOf('[')!==-1){re=/\[([^\]]+)?\]/;}else{re=/_([^\]]+)?_/;} 11id=re.exec(name)&&re.exec(name)[1];if(id){return id;}} 12$.catalog=$.catalog||{};$.catalog.priceUtils={formatPriceLocale:formatPriceLocale,formatPrice:formatPrice,deepClone:objectDeepClone,strPad:stringPad,findOptionId:findOptionId};$.breezemap['Magento_Catalog/js/price-utils']=$.catalog.priceUtils;})();(function(){'use strict';$(document).on('breeze:load',function(){window.ItemTemplate='<li class="swiper-slide">'+'<div class="item product-item-info" data-price="<%- data.price %>" data-category="<%- data.category %>" data-id="<%- data.entity_id %>" data-product-name="<%- data.product_name %>">'+'<div class="product-item-photo product-img">'+'<a href="<%- data.product_url %>">'+'<img alt="<%- data.product_name %>" src="<%- data.product_image %>" decoding="async" fetchpriority="low" loading="lazy" width="240" height="240" />'+'<span><%= data.product_label %></span>'+'</a>'+'</div>'+'<div class="product-item-details">'+'<div class="product-name product-item-name">'+'<a class="product-item-link" title="<%- data.product_name %>" href="<%- data.product_url %>">'+'<span><%- data.product_name %></span>'+'</a>'+'</div>'+'</div>'+'<div class="price-range">'+'<a title="<%- data.product_name %>" href="<%- data.product_url %>" class="redirect-arrow-url">'+'<span class="price-start">Starts from</span>'+'<span class="product-price"><%- data.final_price %></span>'+'</a>'+'</div>'+'</div>'+'</li>';window.NewArrivalsItemTemplate='<li class="swiper-slide">'+'<div class="item product-item-info" data-price="<%- data.price %>" data-category="<%- data.category %>" data-id="<%- data.entity_id %>" data-product-name="<%- data.product_name %>">'+'<div class="product-item-photo product-img">
12'+'<a href="<%- data.product_url %>">'+'<img alt="<%- data.product_name %>" src="<%- data.product_image %>" decoding="async" fetchpriority="low" loading="lazy" width="146" height="146" />'+'<span><%= data.product_label %></span>'+'</a>'+'</div>'+'<div class="product-item-details">'+'<div class="product-name product-item-name">'+'<a class="product-item-link" title="<%- data.product_name %>" href="<%- data.product_url %>">'+'<span><%- data.product_name %></span>'+'</a>'+'</div>'+'<div class="pro-type"><%- data.usp %> </div>'+'<div class="price-main">'+'<a title="<%- data.product_name %>" href="<%- data.product_url %>" class="redirect-arrow-url">'+'<span class="product-price"><%- data.final_price %></span>'+'</a>'+'</div>'+'</div>'+'<div class="button-section">'+'<a title="<%- data.product_name %>" href="<%- data.product_url %>" title="<%- data.product_name %>" class="explore-button primary-button">Explore Now</a>'+'</div>'+'</div>'+'</li>';$.widget('mage.homepage_personalize',{component:'CP_Homepagereview/js/personalization',options:{ItemWrapperTemplate:'<div class="products wrapper products-grid homepage-products mostLoved">'+'<div class="swiper-container">'+'<ul class="swiper-wrapper"><%= data.productsHtml %></ul>'+'</div>'+'<div id="swiper-button-most-loved-prev" class="swiper-button-prev swiper-button-disabled"></div>'+'<div id="swiper-button-most-loved-next" class="swiper-button-next"></div>'+'</div>',PastItemWrapperTemplate:'<div class="products wrapper products-grid cart-past-purchase order-past">'+'<div class="swiper-container">'+'<ol class="swiper-wrapper"><%= data.pastItemsHtml %></ol>'+'</div>'+'<div id="swiper-button-past-purchase-prev" class="swiper-button-prev swiper-button-tarp-white swiper-button-disabled"></div>'+'<div id="swiper-button-past-purchase-next" class="swiper-button-next swiper-button-tarp-white"></div>'+'</div>'+'<%= data.freeShippingNote %>',CartItemWrapperTemplate:'<div class="<%- data.cartItemclass %>">'+'<ol class="products list items product-items cart-products-ol">'+'<%= data.cartItemsHtml %>'+'<% if (data.itemsCount > 0) { %>'+'<div class="cart-products-count-ol visible">'+'<a class="action viewcart" title="View and Edit Cart" href="<%- data.checkout_url %>">'+'<span><%= data.itemsCountText %></span>'+'</a>'+'</div>'+'<% } %>'+'<% if (data.itemsCount == 0) { %>'+'<div class="cart-products-count-ol hidden">'+'<a class="action viewcart" title="View and Edit Cart" href="<%- data.checkout_url %>">'+'<span><%= data.itemsCountText %></span>'+'</a>'+'</div>'+'<% } %>'+'</ol>'+'<div class="cart-action">'+'<ul class="checkout methods">'+'<li class="count-items">'+'<span><%- data.itemsInCart %></span>'+'</li>'+'<li class="item">'+'<button type="button" data-role="proceed-to-checkout" data-id="proceed_checkout" title="Proceed to Checkout" class="action primary checkout homecheckout">'+'<span>Proceed to Checkout</span>'+'</button>'+'</li>'+'<span class="desk-label">'+'<a class="action viewcart" title="View Cart" href="<%- data.checkout_url %>">View Cart</a>'+'<span class="arrow"></span>'+'</span>'+'<% if (data.cartCouponText != 0) { %>'+'<li class="item get-cart-discount">'+'<p><%- data.cartCouponText %></p>'+'</li>'+'<% } %>'+'</ul>'+'</div>'+'</div>'+'<%= data.freeShippingNote %>',CartItemTemplate:'<li class="item product product-item swiper-slide">'+'<div class="item" data-sku="<%- data.product_sku %>" data-product-id="<%- data.product_id %>" data-price="<%- data.custom_price %>" data-position="<%- data.id %>" data-id="<%- data.item_id %>" data-product-name="<%- data.product_name %>" data-sku="<%- data.product_sku %>" data-cat-breadcrum="<%- data.cat_breadcrum %>">'+'<div class="product-item-photo product-img">'+'<a href="<%- data.product_url %>">'+'<img alt="<%- data.product_name %>" src="<%- data.product_image_custom %>" decoding="async" fetchpriority="low" loading="lazy" width="240" height="240" />'+'<span class="product_label"><%= data.product_label %></span>'+'</a>'+'</div>'+'<div class="product-content">'+'<div class="product-name product-item-name">'+'<a class="product-item-link" title="<%- data.product_name %>" href="<%- data.product_url %>">'+'<span><%- data.product_name %></span>'+'</a>
12'+'</div>'+'<div class="product-color-fabric">'+'<% if (typeof data.color_swatch_data != "undefined") { %>'+'<div class="color-swatches"><%= data.color_swatch_data %></div>'+'<% } %>'+'<% if (typeof data.product_color_swatch != "undefined") { %>'+'<div class="color-swatches"><%= data.product_color_swatch %></div>'+'<% } %>'+'<span class="product-color"><%- data.color %> </span>'+'<span class="product-fabric"><%- data.fabric_type %></span>'+'<% if (typeof data.product_warrenty_cart != "0") { %>'+'<div class="warrenty-cart"><%= data.product_warrenty_cart %></div>'+'<% } %>'+'</div>'+'<% if (typeof data.product_qty_ordered != "undefined") { %>'+'<div class="details-qty qty">'+'<label class="label">Qty: </label>'+'<span class="product-qty"><%- data.product_qty_ordered %></span>'+'</div>'+'<% } %>'+'<% if (typeof data.qty != "undefined") { %>'+'<div class="details-qty qty">'+'<label class="label">Qty:-</label>'+'<span class="product-qty"><%- data.qty %></span>'+'</div>'+'<% } %>'+'<span class="product-price"><%- data.custom_price %></span>'+'<% if (typeof data.addtoCartUrl != "undefined") { %>'+'<a class="action add-to-cart" href=<%- data.addtoCartUrl %>>Add to Cart</a>'+'<% } %>'+'</div>'+'</div>'+'</li>',OrderItemWrapperTemplate:'<div class="<%- data.orderItemclass %>">'+'<ol class="products list items product-items cart-products-ol"><%= data.orderItemsHtml %></ol>'+'<% if (data.itemsCount > 2) { %>'+'<div class="order-products-count-ol visible">'+'<a class="action viewcart" title="View and Edit Cart" href="<%- data.order_view_url %>">'+'<span>'+'<strong><%- data.remainItemsCount %> +</strong>'+'<% if (data.itemsCount === 3) { %>'+'More Item'+'<% } else { %>'+'<% if (data.itemsCount >= 4) { %>'+'More Items'+'<% } %>'+'<% } %>'+'</span>'+'</a>'+'</div>'+'<% } %>'+'<div class="cart-action">'+'<ul class="checkout methods">'+'<li class="count-items">'+'<span>Order Date: <%- data.current_order_date %><br></span>'+'<span>'+'<%- data.itemsCount %>'+'<% if (data.itemsCount >= 2) { %>'+' Items '+'<% } %>'+'<% if (data.itemsCount < 2) { %>'+' Item '+'<% } %>'+'</span>'+'(<%- data.current_order_grandtotal %>)'+'<span class="mobile-label">'+'<a class="action primary checkout homecheckout" title="View Order Items" href="<%- data.order_view_url %>">View Items</a>'+'</span>'+'</li>'+'<li class="item">'+'<% if (data.reorder_post_data != "") { %>'+'<a class="action primary checkout homecheckout order" href="javscript:void(0)" title="Re-Order" data-post="<%- data.reorder_post_data %>">Re-Order</a>'+'<% } %>'+'</li>'+'<span class="desk-label">'+'<a class="action track-order" title="Track Order" href="<%- data.track_order %>">Track Order</a>'+'</span>'+'</ul>'+'</div>'+'</div>'+'<%= data.freeShippingNote %>'},create:function(){var $widget=this;var storeCartItems=[];window.cartitems=undefined;$widget.options.customerData={};$widget.options.personalizeType=0;$widget.options.freeShippingNote="<p class='text-center shipping-note'><span></span>"+$t("Free Shipping On Purchase Of "+$widget.getFormattedPrice($widget.options.shippingPrice)+" & Above");+"</p>";var personalizeType=$widget.getCustomerCustomParam();if(personalizeType==1){var windowObject=setInterval(function(){if(typeof window.cartitems!=undefined){if(typeof window.cartitems!="object"||typeof window.cartitems==undefined){var sections=['cart'];customerData.reload(sections,true);let customerCart=customerData.get('cart')().items;if(customerCart!=undefined){$.each(customerCart,function(_index,item){storeCartItems.push(item);});} 13if(storeCartItems.length>0){window.cartitems=storeCartItems.reverse();}} 14if(window.cartitems!=undefined&&window.cartitems.length>0){$widget.loadCartSection();}else{$(".cms-index-index div#most-loved-section").hide();} 15clearInterval(windowObject);}},100);} 16setTimeout(function(){if($widget.options.customerData.email==undefined&&$.sections.get('customer')().email!=''){$widget.getCustomerCustomParam();} 17if($widget.options.customerData.email!=''&&$.sections.get('customer')().email==''){$widget.getCustomerCustomParam();} 18var hasCustomerFlag=true;var windowObjectNew=setInterval(function(){if(hasCustomerFlag){if($widget.options.customerData.email==undefined||$.sections.get('customer')().email==undefined){$widget.getCustomerCustomParam();}else{hasCustomerFlag=false;clearInterval(windowObjectNew);}}},2000);},2000);},loadCartSection:function(){var $widget=this;var sections=['cart'];customerData.reload(sections,true);setTimeout(function(){let customerCart=customerData.get('cart')().items;let storeCartItems=[];$.each(customerCart,function(_index,item){storeCartItems.push(item);});if(storeCartItems!=undefined&&storeCartItems.length>0){window.cartitems=storeCartItems.reverse();} 19if(window.cartitems==undefined||window.cartitems.length==0){$widget.loadMostLovedSection();}else{let cartItemclass='products wrapper grid products-grid order-past homepage-products custom-home-cart';if(window.cartitems.length==1){cartItemclass='products wrapper grid products-grid order-past homepage-products custom-home-cart single-item';}else if(window.cartitems.length==2){cartItemclass='products wrapper grid products-grid order-past homepage-products custom-home-cart second-item';} 20$("#block-personalize-heading").text($t("Your Cart is waiting"));$("#most-loved-section").addClass("your-cart-is-waiting");$(".cms-index-index div#most-loved-section").show();if($widget.options.cartCouponText==''){$widget.options.cartCouponText=0;} 21let cartItemData='';let cartItems=window.cartitems.slice(0,2);$.each(cartItems,function(_index,item){item.product_name=item.product_name.replace(/'/g,"'");item.product_name=item.product_name.replace(/"/g,'"');item.custom_price=$widget.getFormattedPrice(item.product_price_value_custom);
21if(item.product_type=="configurable"&&item.warranty){if(item.warranty.warranty!=''&&item.warranty.warranty!=null){item.product_warrenty_cart=item.warranty.warranty;}} 22item.id=_index;let cartItemTemplateTemp=_.template($widget.options.CartItemTemplate);cartItemData+=cartItemTemplateTemp({data:item});});let cartWrapperTemplate=_.template($widget.options.CartItemWrapperTemplate);let itemsText=parseInt(window.cartitems.length-2)+"+ <br/> More Items";if(parseInt(window.cartitems.length-2)==1){itemsText=parseInt(window.cartitems.length-2)+"+ <br/> More Item";} 23let cartItemsWrapper=cartWrapperTemplate({data:{"cartItemsHtml":cartItemData,"cartItemclass":cartItemclass,"itemsCount":parseInt(window.cartitems.length-2),"itemsCountText":itemsText,"checkout_url":window.BASE_URL+'checkout/cart',"itemsInCart":$widget.getItemsInCart(),"cartCouponText":$widget.options.cartCouponText,"freeShippingNote":$widget.options.freeShippingNote}});$("#cart-homepage").html(cartItemsWrapper);if($('.recent-most-loved.past-current-order').hasClass('show-loader')&&window.cartitems.length>0){$('.recent-most-loved.past-current-order').removeClass('show-loader');$('.recent-most-loved.past-current-order .personalize-homepage').show();} 24$(document).on('click','.checkout.homecheckout',function(event){$(document).trigger('ajax:proceedToCheckoutHome');var processRunning=$t('Processing');$(event.currentTarget).addClass('processing-loader');$(event.currentTarget).find('span').text(processRunning);window.location.href=window.BASE_URL+'checkout';});}},2000);},loadMostLovedSection:function(){var $widget=this;$("#block-personalize-heading").text($widget.options.titleText);let mostLovedItems='';let mostLovedItemsTemp='';let itemsplit=10;if(window.screen.width<480){itemsplit=2;}else if(window.screen.width>481&&window.screen.width<640){itemsplit=3;}else if(window.screen.width>641&&window.screen.width<767){itemsplit=4;}else if(window.screen.width>768&&window.screen.width<1024){itemsplit=5;} 25$.each($widget.options.productValues,function(_index,item){if(Number(item.average_rating)>0){item.average_rating=Number(item.average_rating).toFixed(1);}else{item.average_rating=0;} 26let colorswatches='';if(item.simple_colors.length>0||item.configurable_colors.length>0){if(item.product_type=='simple'&&item.simple_colors.length>0){$.each(item.simple_colors,function(indexColor,itemColor){if(indexColor<4&&itemColor!=undefined){let colorClass='color-swatch ';if(!_.isNull(itemColor)){colorClass+=itemColor.toLowerCase().split(" ").join("-");} 27colorswatches+='<span class="'+colorClass+'">'+itemColor+'</span>';}});if(item.simple_colors.length>4){colorswatches+='<span>+ '+(item.simple_colors.length-4)+'</span>';}} 28if(item.product_type=='configurable'&&item.configurable_colors.length>0){$.each(item.configurable_colors,function(indexColor,itemColor){if(indexColor<4){if(itemColor.type=='image'){colorswatches+='<span class="color-swatch">';colorswatches+='<img src="'+itemColor.value+'" fetchpriority="low" loading="lazy" height="20px" width="20px" alt="color swatch">';colorswatches+='</span>';}else{colorswatches+='<span class="color-swatch" style="background:'+itemColor.value+'"></span>';}}});if(item.configurable_colors.length>4){colorswatches+='<span>+ '+(item.configurable_colors.length-4)+'</span>';}} 29item.color_variants=colorswatches;}else{item.color_variants='';} 30item.product_name=JSON.parse(item.product_name);item.final_price=item.price;var productItemTemplate=_.template(window.ItemTemplate);var mostLovedItemTemp=productItemTemplate({data:item});mostLovedItems=mostLovedItems+mostLovedItemTemp;if(_index<itemsplit){mostLovedItemsTemp=mostLovedItemsTemp+mostLovedItemTemp;}});var productWrapperTemplateTemp=_.template($widget.options.ItemWrapperTemplate);var mostLovedItemTempWrapper=productWrapperTemplateTemp({data:{"productsHtml":mostLovedItemsTemp}});var productWrapperTemplate=_.template($widget.options.ItemWrapperTemplate);var mostLovedItemWrapper=productWrapperTemplate({data:{"productsHtml":mostLovedItems}});$("#cart-homepage").html(mostLovedItemTempWrapper);setTimeout(function(){if($('.homepage-products.mostLoved .swiper-container').length&&typeof Swiper=='function'){window.swiperMostloved=new Swiper(".homepage-products.mostLoved .swiper-container",{"slidesPerView":6.3,"slidesToScroll":1,"freeMode":true,"loop":false,"slidesOffsetBefore":0,"slidesOffsetAfter":0,"spaceBetween":0,"lazy":true,"preloadImages":false,"watchOverflow":true,"navigation":{"nextEl":"#swiper-button-most-loved-next","prevEl":"#swiper-button-most-loved-prev"},"breakpoints":{"480":{"navigation":false,"slidesPerView":1.5},"640":{"slidesPerView":1.5},"767":{"slidesPerView":2.5}
30,"768":{"slidesPerView":3},"1023":{"slidesPerView":3},"1024":{"slidesPerView":3},"1366":{"slidesPerView":5},"1400":{"slidesPerView":5},"1440":{"slidesPerView":6.3}}});}},100);document.addEventListener('scroll',function(){if($(document).find("#cart-homepage > .homepage-products.mostLoved").length>0){if(window.swiperMostloved!=undefined){window.swiperMostloved.destroy();} 31$("#cart-homepage").html(mostLovedItemTempWrapper);$('.recent-most-loved.past-current-order').removeClass('show-loader');$('.recent-most-loved.past-current-order .personalize-homepage').show();if($('.homepage-products.mostLoved .swiper-container').length&&typeof Swiper=='function'){window.swiperMostloved=new Swiper(".homepage-products.mostLoved .swiper-container",{"slidesPerView":6.3,"slidesToScroll":1,"freeMode":true,"loop":false,"slidesOffsetBefore":0,"slidesOffsetAfter":0,"spaceBetween":0,"lazy":true,"preloadImages":false,"watchOverflow":true,"navigation":{"nextEl":"#swiper-button-most-loved-next","prevEl":"#swiper-button-most-loved-prev"},"breakpoints":{"480":{"navigation":false,"slidesPerView":1.5},"640":{"slidesPerView":1.5},"767":{"slidesPerView":2.5},"768":{"slidesPerView":3},"1023":{"slidesPerView":3},"1024":{"slidesPerView":3},"1366":{"slidesPerView":5},"1400":{"slidesPerView":5},"1440":{"slidesPerView":6.3}}});}}},{once:true,passive:true});},getItemsInCart:function(){var price=this.getFormattedPrice(customerData.get('cart')().subtotalAmount);if(window.cartitems.length==1){return $t(window.cartitems.length+" Item in your cart ("+price+")");} 32return $t(window.cartitems.length+" Items in your cart ("+price+")");},getFormattedPrice:function(price){var $widget=this;
32var priceFormat={decimalSymbol:'.',groupLength:3,groupSymbol:",",integerRequired:false,pattern:$widget.options.currencySymbol+"%s",precision:2,requiredPrecision:2};if(price){price=parseFloat(price.toString().replace(',',''));} 33return $.catalog.priceUtils.formatPrice(price,priceFormat);},getCustomerCustomParam:function(){var $widget=this;if($.sections.get('customer')()!=false&&$.sections.get('customer')().email!=undefined&&$.sections.get('customer')().email.length>0){$widget.options.customerData=$.sections.get('customer')();$.ajax({url:window.BASE_URL+'homepagereview/index/homepersonalize',data:'',global:false,contentType:'application/json',type:'GET',async:false,success:function(response){$widget.options.personalizeType=2;let orderData=response.currentOrder.orderData;let orderItemData=response.currentOrder.orderItemData;let storeCartItems=[];if(orderData!=undefined&&orderItemData.length>0){$("#block-personalize-heading").text($t("Your Order"));let orderItemclass='products wrapper grid products-grid homepage-products custom-home-cart order-past your-order';if(orderData.order_item_count==1){orderItemclass='products wrapper grid products-grid homepage-products custom-home-cart order-past your-order single-item';}else if(orderData.order_item_count==2){orderItemclass='products wrapper grid products-grid homepage-products custom-home-cart order-past your-order second-item';} 34let orderItemsData='';$.each(orderItemData,function(_index,item){item.custom_price=$widget.getFormattedPrice(item.product_price);item.id=_index;item.product_name=JSON.parse(item.product_name);item.product_image_custom=item.product_image_url;item.fabric_type=item.product_fabric;item.color=item.product_color;let orderItemTemplateTemp=_.template($widget.options.CartItemTemplate);orderItemsData+=orderItemTemplateTemp({data:item});});let orderWrapperTemplate=_.template($widget.options.OrderItemWrapperTemplate);let orderItemsWrapper=orderWrapperTemplate({data:{"orderItemsHtml":orderItemsData,"orderItemclass":orderItemclass,"itemsCount":parseInt(orderData.order_item_count),"remainItemsCount":parseInt(orderData.order_item_count-2),"order_view_url":window.BASE_URL+'sales/order/view/order_id/'+orderData.current_order_id,"current_order_date":orderData.current_order_date,"current_order_grandtotal":$widget.getFormattedPrice(orderData.current_order_grandtotal),"track_order":window.BASE_URL+'sales/guest/form',"reorder_post_data":orderData.reorder_post_data,"freeShippingNote":$widget.options.freeShippingNote}});$("#cart-homepage").html(orderItemsWrapper);$('.recent-most-loved.past-current-order').removeClass('show-loader');$('.recent-most-loved.past-current-order .personalize-homepage').show();}else if(response.pastOrder.length>0){var sections=['cart'];let customerCart=customerData.get('cart')().items;$.each(customerCart,function(_index,item){storeCartItems.push(item);});if(storeCartItems!=undefined&&storeCartItems.length>0){window.cartitems=storeCartItems.reverse();} 35if(window.cartitems!=undefined&&window.cartitems.length>0){$widget.loadCartSection();}else{$("#block-personalize-heading").text($t("Your Past Purchase"));let orderPastItemsData='';$.each(response.pastOrder,function(_index,item){item.custom_price=$widget.getFormattedPrice(item.product_price);item.id=_index;item.product_name=JSON.parse(item.product_name);item.product_image_custom=item.product_image_url;item.fabric_type=item.product_fabric;item.color=item.product_color;item.addtoCartUrl=window.BASE_URL+'product/product/addOrderItem/order_item_id/'+item.item_id;let orderItemTemplateTemp=_.template($widget.options.CartItemTemplate);orderPastItemsData+=orderItemTemplateTemp({data:item});});let pastItemWrapperTemplate=_.template($widget.options.PastItemWrapperTemplate);let pastItemsWrapper=pastItemWrapperTemplate({data:{"pastItemsHtml":orderPastItemsData,"freeShippingNote":$widget.options.freeShippingNote}});$("#cart-homepage").html(pastItemsWrapper);if(response.pastOrder.length<3){$(".cart-past-purchase.order-past").addClass("custom"+response.pastOrder.length);} 36setTimeout(function(){if($('.cart-past-purchase.order-past .swiper-container').length&&typeof Swiper=='function'){window.swiperPastPurchase=new Swiper(".cart-past-purchase.order-past .swiper-container",{"slidesPerView":3,"slidesToScroll":1,"freeMode":false,"loop":false,"spaceBetween":11,"lazy":true,"preloadImages":false,"watchOverflow":true,"navigation":{"nextEl":"#swiper-button-past-purchase-next","prevEl":"#swiper-button-past-purchase-prev"},"breakpoints":{"320":{"navigation":false,"slidesPerView":1.5},"480":{"navigation":false,"slidesPerView":1.5},"640":{"slidesPerView":1.5},"767":{"navigation":false,"slidesPerView":1.10},"1023":{"navigation":false,"slidesPerView":2.10},"1366":{"slidesPerView":3}}});}},100);} 37$('.recent-most-loved.past-current-order').removeClass('show-loader');$('.recent-most-loved.past-current-order .personalize-homepage').show();}else{var sections=['cart'];customerData.reload(sections,true);setTimeout(function(){let customerCart=customerData.get('cart')().items;$.each(customerCart,function(_index,item){storeCartItems.push(item);});if(storeCartItems!=undefined&&storeCartItems.length>0){window.cartitems=storeCartItems.reverse();} 38if(window.cartitems!=undefined&&window.cartitems.length>0){$widget.loadCartSection();}else{$widget.loadMostLovedSection();}},2000);} 39return $widget.options.personalizeType;}});}else{this.options.personalizeType=1;return this.options.personalizeType;}},destroy:function(){this._super();}});});})();(function(){'use strict';$.widget('mage.homepage_new_arrival',{component:'CP_Homepagereview/js/homepage_new_arrival',options:{ItemWrapperTemplate:'<div class="swiper-container">'+'<ul class="swiper-wrapper" id="home-new-arrival-products"><%= data.productsHtml %></ul>'+'</div>'+'<div id="swiper-button-new-arrivals-prev" class="swiper-button-prev swiper-button-disabled"></div>'+'<div id="swiper-button-new-arrivals-next" class="swiper-button-next"></div>'},create:function(){var $widget=this;let newArrivalItems='';$.each($widget.options.productValues,function(_index,item){if(Number(item.average_rating)>0){item.average_rating=Number(item.average_rating).toFixed(1);}else{item.average_rating=0;} 40item.product_name=JSON.parse(item.product_name);let colorswatches='';if(item.simple_colors.length>0||item.configurable_colors.length>0){if(item.product_type=='simple'&&item.simple_colors.length>0){$.each(item.simple_colors,function(indexColor,itemColor){if(indexColor<4&&itemColor!=undefined){let colorClass='color-swatch';
40if(!_.isNull(itemColor)){colorClass='color-swatch '+itemColor.toLowerCase().split(" ").join("-");} 41colorswatches+='<span class="color-swatch" class="'+colorClass+'">'+itemColor+'</span>';}});if(item.simple_colors.length>4){colorswatches+='<span>+ '+(item.simple_colors.length-4)+'</span>';}} 42if(item.product_type=='configurable'&&item.configurable_colors.length>0){$.each(item.configurable_colors,function(indexColor,itemColor){if(indexColor<4){if(itemColor.type=='image'){colorswatches+='<span class="color-swatch">';colorswatches+='<img src="'+itemColor.value+'" fetchpriority="low" loading="lazy" height="20px" width="20px" alt="color swatch">';colorswatches+='</span>';}else{colorswatches+='<span class="color-swatch" style="background:'+itemColor.value+'"></span>';}}});if(item.configurable_colors.length>4){colorswatches+='<span>+ '+(item.configurable_colors.length-4)+'</span>';}} 43item.color_variants=colorswatches;}else{item.color_variants='';} 44item.final_price=item.price;item.usp=item.usp_type;item.newProduct=1;var productItemTemplate=_.template(window.NewArrivalsItemTemplate);var newArrivalItemTemp=productItemTemplate({data:item});newArrivalItems=newArrivalItems+newArrivalItemTemp;});var productWrapperTemplate=_.template($widget.options.ItemWrapperTemplate);var newArrivalItemWrapper=productWrapperTemplate({data:{"productsHtml":newArrivalItems}});document.addEventListener('scroll',function(){$(".home-new-arrival .block-content.content").html(newArrivalItemWrapper);if($('.homepage-products.newArrival .swiper-container').length&&typeof Swiper=='function'){window.swipernewArrival=new Swiper(".homepage-products.newArrival .swiper-container",$widget.options.swiperConfig);}},{once:true,passive:true});},destroy:function(){this._super();}});})();(function(){'use strict';$.widget('mage.homepage_tarpsbycolor',{component:'CP_Homepagereview/js/homepage_tarpsbycolor',options:{ItemWrapperTemplate:'<div class="swiper-container">'+'<ul class="swiper-wrapper" id="home-tarps-by-color"><%= data.productsHtml %></ul>'+'<div class="swiper-pagination" id="swiper-pagination-tab"></div>'+'</div>'+'<div id="swiper-button-tarps-by-color-prev" class="swiper-button-prev swiper-button-disabled"></div>'+'<div id="swiper-button-tarps-by-color-next" class="swiper-button-next"></div>'},create:function(){var $widget=this;let tarpsByColorItems='';$.each($widget.options.productValues,function(_index,item){item.product_name=JSON.parse(item.product_name);item.final_price=item.price;var productItemTemplate=_.template(window.ItemTemplate);var tarpsByColorItemTemp=productItemTemplate({data:item});tarpsByColorItems=tarpsByColorItems+tarpsByColorItemTemp;});var productWrapperTemplate=_.template($widget.options.ItemWrapperTemplate);var tarpsByColorItemWrapper=productWrapperTemplate({data:{"productsHtml":tarpsByColorItems}});document.addEventListener('scroll',function(){$(".home-tarpsbycolor .block-content.content").html(tarpsByColorItemWrapper);if($('.homepage-products.tarpsbycolor .swiper-container').length&&typeof Swiper=='function'){window.swipertarpsByColor=new Swiper(".homepage-products.tarpsbycolor .swiper-container",$widget.options.swiperConfig);}},{once:true,passive:true});},destroy:function(){this._super();}});})();define(['jquery','uiComponent','ko','mage/template','Magento_Catalog/js/price-utils','Magento_Customer/js/customer-data'],function($,Component,ko,template,priceUtils,customerData){'use strict';$(document).on('breeze:load',function(){var popularTarpLeft=$('.popular-tarp-left');var desktopCategory=$('#desktop-category');var mobileCategory=$('.size-category-item');
44if(window.innerWidth<993){popularTarpLeft.addClass('hide');mobileCategory.removeClass('hide');desktopCategory.addClass('hide');$(".size-category-item").each(function(){var id=$(this).attr("id");if(id){$("#"+id).collapsible({collapsible:false,active:true,openedState:"_active",saveState:false});}});var checkAndClickTarpItem=setInterval(function(){if($('#size-category-item-0 .tarp-item').length){$('#size-category-item-0 .tarp-item').click();clearInterval(checkAndClickTarpItem);} 45sizesTrigger();},1000);}else{var checkAndClickTarpItem=setInterval(function(){if($('.tarp-item').length){$('.tarp-item').eq(0).click();clearInterval(checkAndClickTarpItem);} 46sizesTrigger();},1000);popularTarpLeft.removeClass('hide');handleHoverImage();} 47function sizesTrigger(){setTimeout(function(){var selectedSize=$('input[name=size]:checked');if(selectedSize.length){selectedSize.trigger('change');}},500);} 48function handleHoverImage(){var tarpItems=document.querySelectorAll('.tarp-item');tarpItems.forEach(function(item){item.addEventListener('mouseover',function(){var img=item.querySelector('img');var hoverImgSrc=item.querySelector('#hover-img-src').value;img.src=hoverImgSrc;});item.addEventListener('mouseout',function(){var img=item.querySelector('img');var sizeCategoryItem=item.closest('.size-category-item');
48if(sizeCategoryItem&&sizeCategoryItem.classList.contains('active')){return;} 49img.src=img.getAttribute('data-original-src');});var img=item.querySelector('img');});} 50var currentHoveredItem=null;$(document).on('click','.tarp-item',function(){var parentCategoryItem=$(this).closest('.size-category-item');$('.size-category-item').removeClass('active');parentCategoryItem.addClass('active');if(currentHoveredItem){var originalImgSrc=currentHoveredItem.querySelector('img').getAttribute('data-original-src');currentHoveredItem.querySelector('img').src=originalImgSrc;} 51var img=$(this).find('img');var hoverImgSrc=$(this).find('#hover-img-src').val();img.attr('src',hoverImgSrc);currentHoveredItem=this;var tarpId=$(this).data('tarp-id');var $tarpElement=$('#populartarpdetails_'+tarpId);var $tarpDetailsTemplate=$('#tarp-details-template_'+tarpId);var $tarpsizeElement=$('#size-list-'+tarpId);var $tarpSizeDetailsTemplate=$('#size-template-'+tarpId);if($tarpDetailsTemplate.length&&$tarpSizeDetailsTemplate.length){console.warn("Tamplate renderer");var compiledTemplate=template('#tarp-details-template_'+tarpId);$('.populartarp').hide();$tarpElement.toggle();var sizeTemplate=template('#size-template-'+tarpId);$('.popular-tarp-right').hide();$tarpsizeElement.toggle();var catSizeDetails=$('.popular-tarp-sizes');$.ajax({url:'populartarps/tarp/sizes',type:'POST',data:{tarp_id:tarpId},dataType:'json',beforeSend:function(){catSizeDetails.addClass("disabled");catSizeDetails.css('opacity',0.5);catSizeDetails.spinner(true,{css:{}});},success:function(response){if(compiledTemplate&&sizeTemplate){updateTarpsDetail(response,compiledTemplate);updateSizeList(response,sizeTemplate);sizesTrigger();}},complete:function(){catSizeDetails.removeClass("disabled");catSizeDetails.css('opacity','');catSizeDetails.spinner(false);},error:function(error){console.error(error);}});}else{$('.populartarp').hide();$tarpElement.toggle();$('.popular-tarp-right').hide();$tarpsizeElement.toggle();$tarpsizeElement.find('li input[type="radio"]').first().trigger('click');}});function updateTarpsDetail(tarpDetails,tarpDetailsTemplate){var tarpDetailsContainer=$('#populartarpdetails_'+tarpDetails.tarpsId);tarpDetailsContainer.empty();var renderedTarpDetails=tarpDetailsTemplate(tarpDetails.tarps);tarpDetailsContainer.append(renderedTarpDetails);} 52function updateSizeList(response,sizeTemplate){var tarpId=response.tarpsId 53var sizeList=$('#size-list-'+tarpId);sizeList.empty();if(response&&response.sizes&&response.sizes.length>0&&response.dimension&&response.dimension.length>0){var sizes=response.sizes,dimensions=response.dimension,discountPercentage=response.discountPercentage,prices;if(response.productConfig.is_dynamic_formula==1){priceCalculationOfDynamic(response);}else{} 54var sizeData=sizes.map(function(size,index){return{size:size,price:window.dimensionPrice[index],discount:discountPercentage>0?discountPercentage:0};});var renderedSize=sizeTemplate({sizeData:sizeData,dimension:dimensions,standardDimensions:response.productstandardDimensions,productConfig:encodeURIComponent(JSON.stringify(response.productConfig))});sizeList.append(renderedSize);}else if(response&&response.sizes&&response.sizes.length>0&&response.sizes[0].productType=='simple'){var sizes=response.sizes,colors=response.colors,discountPercentage=response.discountPercentage;var sizeData=sizes.map(function(size,index){var priceData={formatedPrice:getFormattedPrice(size.productprice)};if(discountPercentage>0){priceData.formatedOldPrice=getFormattedPrice(roundLikePHP((size.productprice*100)/(100-discountPercentage),2));} 55return{size:size,price:priceData,discount:discountPercentage>0?discountPercentage:0};});var renderedSize=sizeTemplate({sizeData:sizeData,dimension:[],colors:colors,productType:response.sizes[0].productType,standardDimensions:"",productConfig:""});sizeList.append(renderedSize);}else{console.error('Response or its properties are undefined.');}} 56function getFormattedPrice(price){return priceUtils.formatPrice(price,window.priceFormat);} 57function roundLikePHP(num,dec){var num_sign=num>=0?1:-1;return parseFloat((Math.round((num*Math.pow(10,dec))+(num_sign*0.0001))/ Math.pow(10,dec)).toFixed(dec));} 58$(document).on('submit','.tarps-by-size',function(e){e.preventDefault();let form=$(this);let formId=form.attr('id');var addToCartButton=form.find('.size-footer-right');var selectedSize=$('#'+formId+' input[name=size]:checked');let productType=form.find('[name="productType"]').val();if(productType=='simple'){var selectedColor=$('#'+formId+' input[name=colors]:checked');if(selectedSize.length>0&&selectedColor.length>0){var selectedProductUrl=selectedSize.data('producturl');var selectedDimension=selectedSize.data('dimension');var productId=selectedSize.data('productid');var options={};options[selectedDimension.optionId]=selectedDimension.id;options[selectedColor.data('optionid')]=selectedColor.val();$.ajax({url:'populartarps/tarp/checkout',type:form.attr('method'),data:{product_id:productId,qty:'1',options:options},dataType:'json',beforeSend:function(){addToCartButton.addClass("disabled");addToCartButton.css('opacity',0.5);addToCartButton.spinner(true,{css:{}});},success:function(response){if(response.success){var sections=['cart'];customerData.invalidate(sections);customerData.reload(sections,true);window.location.href='/checkout/cart/';setTimeout(function(){addToCartButton.removeClass("disabled");addToCartButton.css('opacity','');addToCartButton.spinner(false);},1000);}else{$('.tarp-section-error').html('<div class="error-message">'+response.message+'</div>');addToCartButton.removeClass("disabled");addToCartButton.css('opacity','');addToCartButton.spinner(false);}},error:function(error){$('.tarp-section-error').html('<div class="error-message">
58An error occurred. Please try again.</div>');console.error(error);}});}}else{if(selectedSize.length>0){addToCartButton.addClass("disabled");addToCartButton.css('opacity',0.5);addToCartButton.spinner(true,{css:{}});var selectedProductUrl=selectedSize.data('producturl');var selectedDimension={};var customSizeInputs=$('#'+formId+' .customsize-text');if(selectedSize.attr('id')==='customsize'){var hasEmptyInput=false;customSizeInputs.each(function(){var dimensionKey=this.id;var dimensionValue=$(this).val();var intValue=parseInt(dimensionValue,10);$(this).removeClass('empty-input');$(this).next('.error-text').remove();if(dimensionValue===''||intValue<=0){hasEmptyInput=true;$(this).addClass('empty-input');if(intValue<=0){$(this).after('<span class="error-text">Please enter a size greater than 0.</span>');}}else{selectedDimension[dimensionKey]=dimensionValue;}});if(hasEmptyInput){addToCartButton.removeClass("disabled");addToCartButton.css('opacity','');addToCartButton.spinner(false);return;}}else{selectedDimension=selectedSize.data('dimension');} 59var sizeQueryParam=objectToQueryString(selectedDimension) 60window.location.href=selectedProductUrl+'?'+sizeQueryParam;}else{var errorMessage='Please select a size before start order.';$('.tarp-section-error').html('<div class="error-message">'+errorMessage+'</div>');return;}}});function objectToQueryString(obj){var queryString='';for(var key in obj){if(obj.hasOwnProperty(key)){queryString+=encodeURIComponent(key)+'='+encodeURIComponent(obj[key])+'&';}} 61queryString=queryString.slice(0,-1);return queryString;} 62$(document).on('change','input[name=size]',function(){var form=$(this).closest('form');var selectedSize=form.find('input[name=size]:checked');var sizeFooter=form.find('.size-footer');var price="$0.00";var oldPrice="$0.00";var discount='';var inputFields=document.querySelectorAll('.customsize-text');if(selectedSize.length>0&&selectedSize.attr('id')!=='customsize'){inputFields.forEach(function(inputField){inputField.value='';inputField.disabled=true;});price=selectedSize.data('price');discount=parseFloat(selectedSize.data('discount'))||0;if(discount>0){oldPrice=selectedSize.data('old-price');discount=discount+'% OFF';}else{oldPrice='';discount='';}}else if(selectedSize.attr('id')=='customsize'){inputFields.forEach(function(inputField){inputField.disabled=false;});} 63sizeFooter.find('.price').text(price);sizeFooter.find('.old-price').text(oldPrice);if(price!=="0.00"&&discount){sizeFooter.find('.discount').html('<span>'+discount+'</span>');}else{sizeFooter.find('.discount').empty();}});function priceCalculationOfDynamic(response){window.productConfig=response.productConfig;window.$dynamicFormula=JSON.parse(response.productConfig.dynamic_formula);window.priceFormula=response.productConfig.priceFormula;window.unitPriceRate=response.unitPriceRate;var dimensionPriceTemp=[];var totalPrice=0;var sizes=response.sizes;var productConfig=response.productConfig;var $dynamicFormula=JSON.parse(response.productConfig.dynamic_formula);var priceFormula=response.productConfig.priceFormula;var discountPercentage=response.discountPercentage;window.dimentionChangeFlag=window.isLeewayRemove?0:1;window.defaultDiamention=response.dimension;window.adjustment=JSON.parse(response.productConfig.adjustment);window.additional=response.productConfig.additional;window.priceMultiplier=response.productConfig.priceMultiplier;var $widgettotalsqft=0;var defaultFormula='';
63sizes.forEach(function(size,_index){var $fixedSizes=JSON.parse(size.fixedsize.replace(/\\/g,""));try{let isMatch=true;if(Array.isArray(response.dimension)&&typeof $fixedSizes==='object'&&$fixedSizes!==null){response.dimension.forEach(item=>{if(!item||typeof item.value==='undefined')return;const key=item.value;const expected=String(item.defaultvalue??'');const actual=String($fixedSizes[key]??'');var actualConverted=String(getInchtoFtValue(actual,window.productConfig));if(expected!==actualConverted){isMatch=false;}});window.dimentionChangeFlag=isMatch?0:window.isLeewayRemove?0:1;}else{console.warn("Invalid input: response.dimension or $fixedSizes is not in expected format");}}catch(error){console.error("Error during dimension comparison:",error);} 64var productPrieFixed=size.productprice;var dimentionarr=Object.values($fixedSizes);var maxValue=Math.max.apply(null,dimentionarr);var maxValue=getInchtoFtValue(maxValue,window.productConfig);if(productConfig.formula&&productConfig.formula!==""){var formula=productConfig.formula;var fabricDivId=formula.fabric_type;var fabricValue=productConfig.formula.unit_price;var rollSize=getSelectedFabricRoll(JSON.parse(productConfig.fabricMaterial),fabricDivId);$.each($dynamicFormula,function(_findex,fitemVal){if(fitemVal.fabric_type==fabricDivId){priceFormula=fitemVal.formula;defaultFormula=fitemVal.default_formula;var totalsqft=0;var defaultFormulaValue=0;var flagOfMax=0;$.each($fixedSizes,function(_index,item){var itemValue=getInchtoFtValue(item,response.productConfig);if(maxValue==Number(itemValue)&&maxValue!=0&&window.dimentionChangeFlag!=0&&rollSize>0&&flagOfMax==0){var itemVal=Number(itemValue)+Number(Math.floor(Number(itemValue / rollSize))*2.5 / 12);itemVal=_calculateItemVal(itemVal,1);
64flagOfMax=1;}else{var itemVal=_calculateItemVal(Number(itemValue),1);} 65var id=_index;var pattern=new RegExp('\\b'+id+'\\b','g');if(itemVal>0){var itemValue=Number($(item).val());priceFormula=priceFormula.replace(pattern,itemVal);defaultFormula=defaultFormula.replace(pattern,itemVal);}else{priceFormula=priceFormula.replace(pattern,0);defaultFormula=defaultFormula.replace(pattern,0);}});if(priceFormula&&priceFormula!==''){priceFormula=priceFormula.replace('(int)','');} 66if(defaultFormula&&defaultFormula!==''){defaultFormula=defaultFormula.replace('(int)','');} 67totalsqft=eval(priceFormula);defaultFormulaValue=eval(defaultFormula);var condition=eval(defaultFormulaValue+fitemVal.operator+fitemVal.default_value);if(condition){totalPrice=totalsqft;if(window.priceMultiplier!=0||window.priceMultiplier!=''){totalPrice=totalPrice*window.priceMultiplier;} 68$widgettotalsqft=totalPrice;fabricValue=fitemVal.unit_price;}}});totalPrice=$widgettotalsqft;if(typeof window.unitPriceRate!=="undefined"&&!isNaN(window.unitPriceRate)&&window.unitPriceRate>0){totalPrice=totalPrice*window.unitPriceRate;} 69var fabricPrice=roundLikePHP(Number(totalPrice*fabricValue),2);if(discountPercentage>0){var fabricOldPrice=roundLikePHP((Number(totalPrice*fabricValue)*100)/(100-discountPercentage),2);if(productPrieFixed&&!isNaN(Number(productPrieFixed))&&Number(productPrieFixed)>0){fabricPrice=productPrieFixed;fabricOldPrice=roundLikePHP((Number(productPrieFixed)*100)/(100-discountPercentage),2);}}else if(productPrieFixed&&!isNaN(Number(productPrieFixed))&&Number(productPrieFixed)>0){fabricPrice=productPrieFixed;} 70var priceData={formatedPrice:getFormattedPrice(roundLikePHP(fabricPrice,2))};if(discountPercentage>0){priceData.formatedOldPrice=getFormattedPrice(roundLikePHP(fabricOldPrice,2));} 71dimensionPriceTemp.push(priceData);window.dimensionPrice=dimensionPriceTemp;}});} 72function _calculateItemVal(itemValue,flag){window.extra_inches=0;var adjustment=window.adjustment;if(itemValue===0||itemValue==='0'||itemValue===''){return 0;} 73if(!_.isEmpty(adjustment)&&window.dimentionChangeFlag!=0&&window.extra_inches==0){if(flag==1){itemValue=itemValue*12;itemValue=parseFloat(itemValue)+parseFloat(window.additional);} 74if(flag!=1){_.each(adjustment,function(value,_key){if(parseInt(value.to)==0){if(parseFloat(value.from)<=parseFloat(itemValue)){itemValue=parseFloat(itemValue)+parseFloat(value.adjustment);}}else{if(parseFloat(value.from)<=parseFloat(itemValue)&&parseFloat(value.to)>parseFloat(itemValue)){itemValue=parseFloat(itemValue)+parseFloat(value.adjustment);}}});} 75if(flag==1){itemValue=roundLikePHP(Number(itemValue / 12),2);}} 76return itemValue;} 77function getSelectedFabricRoll(fabricMaterial,fabricID){var fabricRollSize='';$.each(fabricMaterial,function(_fabricId,fabricRoll){if(Number(_fabricId)==Number(fabricID)){fabricRollSize=fabricRoll;return false;}});return parseFloat(fabricRollSize);} 78function getInchtoFtValue(item,productConfig){if(productConfig.is_dynamic_formula==1&&productConfig.product_measurement!=='feet'){item=getConvertMeasure(productConfig.product_measurement,'feet',item,productConfig);} 79return item;} 80function getConvertMeasure(currMeasure,reqMeasure,itemValue,productConfig){var returnVal='';if(currMeasure=='inch'){returnVal=getInchToReqMeasure(itemValue,returnVal,reqMeasure);} 81else if(currMeasure=='feet'){returnVal=getFeetToReqMeasure(itemValue,returnVal,reqMeasure);} 82else if(currMeasure=='mm'){returnVal=getMmToReqMeasure(itemValue,returnVal,reqMeasure);} 83else if(currMeasure=='cm'){returnVal=getCmToReqMeasure(itemValue,returnVal,reqMeasure);} 84else if(currMeasure=='meter'){returnVal=getMeterToReqMeasure(itemValue,returnVal,reqMeasure);} 85var mainStoreConvert=["tarpsandall","tarps_ca"];var multiStoreConvert=["tarps_au","tarps_uk"];if(mainStoreConvert.includes(productConfig.store_code)){return checkandCovertMeasure(reqMeasure,currMeasure,returnVal);}else if(multiStoreConvert.includes(productConfig.store_code)){var returnFlag=checkConvertMeasure(reqMeasure,currMeasure);if(returnFlag==1){return returnVal;}else{return multiCheckAndRoundMeasure(returnVal,reqMeasure);}}else{return checkandCovertMeasure(reqMeasure,currMeasure,returnVal);}} 86function checkandCovertMeasure(reqMeasure,currMeasure,returnVal){var returnFlag=checkConvertMeasure(reqMeasure,currMeasure);if(returnFlag==1){return roundLikePHP(Number(returnVal),4);}else{return mainCheckAndRoundMeasure(returnVal,reqMeasure);}} 87function mainCheckAndRoundMeasure(returnVal,reqMeasure){if(reqMeasure=='mm'){returnVal=roundLikePHP(Number(returnVal / 10),0)*10;} 88if(reqMeasure=='cm'||reqMeasure=='inch'){returnVal=roundLikePHP(Number(returnVal),0);} 89if(reqMeasure=='meter'){returnVal=roundLikePHP(Number(returnVal),6);} 90if(reqMeasure=='feet'){returnVal=roundLikePHP(Number(returnVal),6);}else{returnVal=roundLikePHP(Number(returnVal),2);} 91return returnVal;} 92function checkConvertMeasure(reqMeasure,currMeasure){var returnFlag=0;if(reqMeasure=='feet'&&currMeasure=='feet'){returnFlag=1;return returnFlag;} 93if(reqMeasure=='mm'&&currMeasure=='mm'){returnFlag=1;return returnFlag;} 94if(reqMeasure=='cm'&&currMeasure=='cm'){returnFlag=1;return returnFlag;} 95if(reqMeasure=='meter'&&currMeasure=='meter'){returnFlag=1;return returnFlag;} 96if(reqMeasure=='inch'&&currMeasure=='inch'){returnFlag=1;return returnFlag;} 97return returnFlag;}
98function multiCheckAndRoundMeasure(returnVal,reqMeasure){if(reqMeasure=='mm'){returnVal=roundLikePHP(Number(returnVal / 10),0)*10;} 99if(reqMeasure=='cm'||reqMeasure=='inch'){returnVal=roundLikePHP(Number(returnVal),0);} 100if(reqMeasure=='meter'){returnVal=roundLikePHP(Number(returnVal),2);} 101if(reqMeasure=='feet'&&returnVal>=0.49){returnVal=roundLikePHP(Number(returnVal /.50)*.50,2);}else{returnVal=roundLikePHP(Number(returnVal),2);} 102return returnVal;} 103function getInchToReqMeasure(itemValue,returnVal,reqMeasure){if(reqMeasure=='feet'){returnVal=parseFloat(itemValue/12);}else if(reqMeasure=='mm'){returnVal=parseFloat(itemValue*25.41);}else if(reqMeasure=='cm'){returnVal=parseFloat(itemValue*2.54);}else if(reqMeasure=='meter'){returnVal=parseFloat(itemValue*0.0254);}else if(reqMeasure=='inch'){returnVal=parseFloat(itemValue);} 104return returnVal;} 105function getFeetToReqMeasure(itemValue,returnVal,reqMeasure){if(reqMeasure=='inch'){returnVal=parseFloat(itemValue*12);}else if(reqMeasure=='mm'){returnVal=parseFloat(itemValue*304.8);}else if(reqMeasure=='cm'){returnVal=parseFloat(itemValue*30.48);}else if(reqMeasure=='meter'){returnVal=parseFloat(itemValue*0.3048);}else if(reqMeasure=='feet'){returnVal=parseFloat(itemValue);} 106return returnVal;} 107function getMmToReqMeasure(itemValue,returnVal,reqMeasure){if(reqMeasure=='inch'){returnVal=parseFloat(itemValue*0.0393701);}else if(reqMeasure=='feet'){returnVal=parseFloat(itemValue*0.00328084);}else if(reqMeasure=='cm'){returnVal=parseFloat(itemValue*0.1);}else if(reqMeasure=='meter'){returnVal=parseFloat(itemValue*0.001);}else if(reqMeasure=='mm'){returnVal=parseFloat(itemValue);} 108return returnVal;} 109function getCmToReqMeasure(itemValue,returnVal,reqMeasure){if(reqMeasure=='inch'){returnVal=parseFloat(itemValue*0.393701);}else if(reqMeasure=='feet'){returnVal=parseFloat(itemValue*0.0328084);}else if(reqMeasure=='mm'){returnVal=parseFloat(itemValue*10);}else if(reqMeasure=='meter'){returnVal=parseFloat(itemValue*0.01);}else if(reqMeasure=='cm'){returnVal=parseFloat(itemValue);} 110return returnVal;} 111function getMeterToReqMeasure(itemValue,returnVal,reqMeasure){if(reqMeasure=='inch'){returnVal=parseFloat(itemValue*39.3701);}else if(reqMeasure=='feet'){returnVal=parseFloat(itemValue*3.28084);}else if(reqMeasure=='mm'){returnVal=parseFloat(itemValue*1000);}else if(reqMeasure=='cm'){returnVal=parseFloat(itemValue*100);}else if(reqMeasure=='meter'){returnVal=parseFloat(itemValue);} 112return returnVal;} 113document.addEventListener('input',function(event){if(event.target.classList.contains('customsize-text')){var formId=event.target.closest('form').id;var productConfigValue=event.target.closest('form').querySelector('#product_config').value;var selectedSize=document.querySelector('#'+formId+' input[name=size]:checked');var selectedDimension={};if(selectedSize.id==='customsize'){var customSizeInputs=document.querySelectorAll('#'+formId+' .customsize-text');customSizeInputs.forEach(function(input){var dimensionKey=input.id;var dimensionValue=input.value;selectedDimension[dimensionKey]=dimensionValue;});} 114priceCalculationForCutomSizes(selectedDimension,formId,productConfigValue);}});function _applyMsppLogic(totalsqft,fabricId){var measurementType="";if($("#customsize").is(":checked")){measurementType="custom";};var msppconfigData=window.productConfig.msppConfig;if(!msppconfigData||!msppconfigData.globelConfig||!msppconfigData.productLevelConfig||(measurementType!="custom")){return{isApplied:false};} 115var msppGlobalConfig=msppconfigData.globelConfig;var msppProductConfig=msppconfigData.productLevelConfig;var $warningBox=$('.mspp-warning-box');var $warningText=$warningBox.find('.warning-text');var msppMessage=msppGlobalConfig.pdpMessage||'MSPP apply on this product.';var msppSqftData=msppProductConfig.msppSqft;var baseSqftValue=null;var unitPrice=null;var totalPrice=null;if(msppSqftData){var parsedSqftData;try{if(typeof msppSqftData==="string"){parsedSqftData=JSON.parse(msppSqftData);}else{parsedSqftData=msppSqftData;} 116if(fabricId&&parsedSqftData[fabricId]&&parsedSqftData[fabricId].base_sqft!==undefined){baseSqftValue=parsedSqftData[fabricId].base_sqft;unitPrice=parsedSqftData[fabricId].unit_price;totalPrice=parsedSqftData[fabricId].price;}}catch(e){baseSqftValue=null;unitPrice=null;totalPrice=null;}} 117var msppSqft=Number(baseSqftValue);var totalSqft=Number(totalsqft);var qty=parseInt($('#qty').val(),10)||1;if(msppGlobalConfig.enabled==1&&msppProductConfig.msppEnable==1&&!isNaN(msppSqft)&&!isNaN(totalSqft)){if(totalSqft<=msppSqft&&(!msppProductConfig.msppThresholdsQty||qty<=msppProductConfig.msppThresholdsQty)){if(msppGlobalConfig.isPdpMsgEnabled==1){$warningText.text(msppMessage);$warningBox.css('display','flex');} 118return{isApplied:true,baseSqftValue:baseSqftValue,unitPrice:unitPrice,finalPrice
118:totalPrice};}} 119$warningBox.hide();return{isApplied:false};};function priceCalculationForCutomSizes(selectedDimension,formId,productConfigValue){var productConfigValue=JSON.parse(decodeURIComponent(productConfigValue));var dimensionPriceTemp=[];var totalPrice=0;var customsizes=selectedDimension;var productConfig=window.productConfig;var $dynamicFormula=JSON.parse(productConfigValue.dynamic_formula);var priceFormula=window.priceFormula;window.dimentionChangeFlag=window.isLeewayRemove?0:1;window.adjustment=JSON.parse(productConfig.adjustment);window.additional=productConfig.additional;window.priceMultiplier=productConfig.priceMultiplier;var $widgettotalsqft=0;var defaultFormula='';let sizes=[{productType:"configurable",fixedsize:JSON.stringify(customsizes)}];sizes.forEach(function(size,_index){var $fixedSizes=JSON.parse(size.fixedsize.replace(/\\/g,""));try{let isMatch=true;if(Array.isArray(window.defaultDiamention)&&typeof selectedDimension==='object'&&selectedDimension!==null){window.defaultDiamention.forEach(item=>{if(!item||typeof item.value==='undefined')return;const key=item.value;const expected=String(item.defaultvalue??'');const actual=String(selectedDimension[key]??'');var actualConverted=String(getInchtoFtValue(actual,window.productConfig));if(expected!==actualConverted){isMatch=false;}});window.dimentionChangeFlag=isMatch?0:window.isLeewayRemove?0:1;}else{console.warn("Invalid input: response.dimension or $fixedSizes is not in expected format");}}catch(error){console.error("Error during dimension comparison:",error);} 120var dimentionarr=Object.values($fixedSizes);var maxValue=Math.max.apply(null,dimentionarr);var maxValue=getInchtoFtValue(maxValue,window.productConfig);if(productConfig.formula&&productConfig.formula!==""){var formula=productConfigValue.formula;var fabricDivId=formula.fabric_type;var fabricValue=productConfig.formula.unit_price;var rollSize=getSelectedFabricRoll(JSON.parse(productConfigValue.fabricMaterial),fabricDivId);$.each($dynamicFormula,function(_findex,fitemVal){if(fitemVal.fabric_type==fabricDivId){priceFormula=fitemVal.formula;defaultFormula=fitemVal.default_formula;var totalsqft=0;var defaultFormulaValue=0;var flagOfMax=0;$.each($fixedSizes,function(_index,item){var itemValue=getInchtoFtValue(item,window.productConfig);if(maxValue==Number(itemValue)&&maxValue!=0&&window.dimentionChangeFlag!=0&&rollSize>0&&flagOfMax==0){var itemVal=Number(itemValue)+Number(Math.floor(Number(itemValue / rollSize))*2.5 / 12);itemVal=_calculateItemVal(itemVal,1);
120flagOfMax=1;}else{var itemVal=_calculateItemVal(Number(itemValue),1);} 121var id=_index;var pattern=new RegExp('\\b'+id+'\\b','g');if(itemVal>0){var itemValue=Number($(item).val());priceFormula=priceFormula.replace(pattern,itemVal);defaultFormula=defaultFormula.replace(pattern,itemVal);}else{priceFormula=priceFormula.replace(pattern,0);defaultFormula=defaultFormula.replace(pattern,0);}});if(priceFormula&&priceFormula!==''){priceFormula=priceFormula.replace('(int)','');} 122if(defaultFormula&&defaultFormula!==''){defaultFormula=defaultFormula.replace('(int)','');} 123totalsqft=eval(priceFormula);defaultFormulaValue=eval(defaultFormula);var condition=eval(defaultFormulaValue+fitemVal.operator+fitemVal.default_value);if(condition){totalPrice=totalsqft;if(window.priceMultiplier!=0||window.priceMultiplier!=''){totalPrice=totalPrice*window.priceMultiplier;} 124$widgettotalsqft=totalPrice;fabricValue=fitemVal.unit_price;}}});totalPrice=$widgettotalsqft;var totPrice=$widgettotalsqft;if(typeof window.unitPriceRate!=="undefined"&&!isNaN(window.unitPriceRate)&&window.unitPriceRate>0){totalPrice=totalPrice*window.unitPriceRate;} 125var fabricPrice=roundLikePHP(Number(totalPrice*fabricValue),2);var fabricOldPrice=roundLikePHP((Number(totalPrice*fabricValue)*100)/(100-window.strikePercentage),2);var measurementType="";if($("#customsize").is(":checked")){measurementType="custom";};var msppData=_applyMsppLogic(totPrice,fabricDivId);if(measurementType==="custom"&&totPrice>0){if(msppData.isApplied){var fabricPrice=msppData.finalPrice*window.unitPriceRate 126var fabricOldPrice=roundLikePHP(Number(msppData.finalPrice)+Number(msppData.finalPrice)*20 / 100,2);}} 127var $standrdDimensionInput=$('#'+formId+' input[type="hidden"][name="standrd_dimension_string"]');if($standrdDimensionInput.length&&$standrdDimensionInput.val().trim()!==''){var standrdDimensionVal=JSON.parse($standrdDimensionInput.val());var $dimensionInput=$('#'+formId+' input.customsize-text');if($dimensionInput.length>0){var values=[];$dimensionInput.each(function(){var val=$(this).val().trim();if(val!==''){values.push(val);}});var dimensionStr=values.join('x');if(dimensionStr!==''){if(dimensionStr in standrdDimensionVal){var stdDimPriceNum=Number(standrdDimensionVal[dimensionStr]);if(!isNaN(stdDimPriceNum)&&stdDimPriceNum>0){var fabricPrice=standrdDimensionVal[dimensionStr];var fabricOldPrice=roundLikePHP((Number(fabricPrice)*100)/(100-window.strikePercentage),2);}}}}} 128var priceData={formatedPrice:getFormattedPrice(roundLikePHP(fabricPrice,2))};var strikePercentage=parseFloat(window.strikePercentage);if(isFinite(strikePercentage)&&strikePercentage>0){priceData.formatedOldPrice=getFormattedPrice(roundLikePHP(fabricOldPrice,2));} 129dimensionPriceTemp.push(priceData);window.customdimensionPrice=dimensionPriceTemp;}});var sizeFooter=$('#'+formId+' .size-footer');sizeFooter.find('.price').text(window.customdimensionPrice[0].formatedPrice);if(window.customdimensionPrice[0].formatedOldPrice){sizeFooter.find('.old-price').text(window.customdimensionPrice[0].formatedOldPrice);}else{sizeFooter.find('.old-price').empty();}}});});
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.