define(['uiComponent','jquery','ko','komapping','Magento_Catalog/js/price-utils','mage/translate','Magento_Customer/js/customer-data','rjsResolver','Sivantos_Catalog/js/eartips'],function(Component,$,ko,komapping,priceUtils,$t,customerData,resolver,eartips){'use strict';return Component.extend({defaults:{baseURL:'',getBinauraltext:$t('Binaural'),getLefttext:$t('Left'),getRighttext:$t('Right'),getBulktext:$t('Bulk'),custom_selection:'',hasLndProductSku:false,isBTEBundle:$('#radioselectors').hasClass('BTEBundle'),isStylettox:$('#radioselectors').hasClass('isstyletto'),isStockBundle:$('.product-add-form').hasClass('StockItemgroup'),patientRefField:$('.product-add-form .product-options-wrapper .product-custom-option'),qty:'',warprice:'',wprice:$('.extended-warranty__product select option:selected').attr('data-price')||0,isearmoldchecked:$('#addEarmold').is(':checked'),bulkqty:$('.box-tocart #qty').val(),getDisplayOrderConfigValue:'',getShowPkgQty:'',BothOrders:'',PatientBasedOrders:'',BulkOrders:'',BinauralSelected:1,RightSelected:2,LeftSelected:3,BulkSelected:4,iscartpage:$('body').hasClass('checkout-cart-configure'),isOnlyBulkOrdersSelected:false,sideRestriction:false},initialize:function(){this._super();var self=this,earprice=0,warprice=0,qty,orderConfigDropdownValues=self.getOrderConfigurationDropdown,charger_price=self.getChargerPrice()*self.getChargerQty(),default_col_price=$('#bundle-summary .Color .options > div').attr('data-bundleprice')||0;if(charger_price){var price=parseFloat(charger_price)+parseFloat(default_col_price);$('.earmold-addon > li').addClass('hascharger');}else{var price=default_col_price;} $(JSON.parse(orderConfigDropdownValues)).each(function(index,item){if(index==0){self.BothOrders=item;} if(index==1){self.PatientBasedOrders=item;} if(index==2){self.BulkOrders=item;}});if($('.product-add-form').hasClass('BTE-RICgroup')){$('.Droit').addClass('Right Receiver');$('.Gauche').addClass('Left Receiver');}else{$('.Droit').addClass('Right');$('.Gauche').addClass('Left');} $('.price-table span.prdprice').empty();$('.price-table span.prdprice').append(priceUtils.formatPrice(price));$('.pricetabletotal').empty();$('.pricetabletotal').append(priceUtils.formatPrice(price));$('.price-table span.earprice').empty();$('.price-table span.earprice').append(priceUtils.formatPrice(earprice));$('.price-table span.warprice').empty();$('.price-table span.warprice').append(priceUtils.formatPrice(warprice));if(self.getDisplayOrderConfigValue==self.BulkOrders){window.onlyBulkOrders=true;self.isOnlyBulkOrdersSelected=true;} self.initFunctions();resolver(function(){window.earmoldCheck=false;this.triggerEarMold();},this);},getChargerPrice:function(){var charger_price=$('#bundle-summary '+window.CHARGER_LABEL+' .options > div').attr('data-bundleprice')||0;return charger_price;},getChargerOldPrice:function(){var chargerOld_price=0;if($('.field'+window.CHARGER_LABEL).find('.product.bundle.option').length){chargerOld_price=$('.field'+window.CHARGER_LABEL).find('.product.bundle.option').attr('data-bundleprice');} return chargerOld_price;},buyingGroup:customerData.get('buying_group'),initFunctions:function(){var self=this;self.setChargerLabel();self.EarmoldProductPriceTable();self.EditableBundleQty();self.EarmoldRICPriceTable();self.PricetableOnChange();self.RadioSelectors();self.BulkQtyOnChange();self.PricetableOnChangeInEdit();self.CheckIfDemoProduct();self.PricetableOnLoad();self.OptionSelectedInBundleEdit(self.custom_selection);self.bindBTEBundleEvents();self.bindStylettoBundleEvents();self.bindBulkOrderCalPrice();self.ChargerCheckbox();self.chargerQtyBox();if(this.hasLndProductSku==true||this.sideRestriction=='Binaural'){if(this.hasLndProductSku==true){$('.product-add-form').addClass('lndProduct');} if(self.custom_selection==''){$('.rightside').prop('checked',true);} self.RadioSelectors();$(".bulkside").each(function(){$(this).addClass('hide');$(this).prop('checked',false);});$(".biside").each(function(){$(this).addClass('hide');});} if(this.sideRestriction=='Monaural'){self.RadioSelectors();$(".r_side").children().each(function(){$(this).addClass('hide');});$(".l_side").children().each(function(){$(this).addClass('hide');});} if(this.sideRestriction=='Bulk'||$.inArray(self.buyingGroup().group_name,self.purchaseChannelsToIgnoreBulk.split(",").map(item=>item.trim()))!==-1){self.RadioSelectors();$(".bulkside").each(function(){$(this).addClass('hide');$(this).prop('checked',false);});} self.getDisplayOrderConfig();if(window.optionalEarwears){$('.Left.Earwear.field').removeClass('required');$('.Right.Earwear.field').removeClass('required');$('.Left.Earwear.field select').removeClass('required');$('.Right.Earwear.field select').removeClass('required');}},setChargerLabel:function(){if($('.fieldset-bundle-options .Charger').length){window.CHARGER_LABEL='.Charger';} if($('.fieldset-bundle-options .Chargeur').length){window.CHARGER_LABEL='.Chargeur';}},getDisplayOrderConfig:function(){var self=this;if(self.getDisplayOrderConfigValue==self.BulkOrders){window.onlyBulkOrders=true;self.isOnlyBulkOrdersSelected=true;$('.product-add-form').addClass('onlyBuklOrders');$('.radio.bulkside').prop('checked',true);if(!self.iscartpage||self.custom_selection!=self.BulkSelected){$('.radio.bulkside').trigger('click');}} if(self.getDisplayOrderConfigValue==self.PatientBasedOrders&&self.iscartpage){if(self.custom_selection==self.BulkSelected){$('.product-add-form').addClass('onlyPatientBased');self.custom_selection=self.BinauralSelected;}}},EarmoldProductPriceTable:function(){if($('.price-table').hasClass('EarMold')){if($('body').hasClass('checkout-cart-configure')){var left_price=$('#bundle-summary .Left .options > div').attr('data-bundleprice')||$('#bundle-summary .Gauche .options > div').attr('data-bundleprice')||0,right_price=$('#bundle-summary .Right .options > div').attr('data-bundleprice')||$('#bundle-summary .Droit .options > div').attr('data-bundleprice')||0;var leftprd_price=left_price;var rightprd_price=right_price;var totalprice=parseFloat(leftprd_price)+parseFloat(rightprd_price);if(totalprice>0){$('.price-table span.prdprice').empty();$('.price-table span.prdprice').append(priceUtils.formatPrice(totalprice));$('.pricetabletotal').empty();$('.pricetabletotal').append(priceUtils.formatPrice(totalprice));}}} if($('.price-table').hasClass('EarMold')){$('.fieldset-bundle-options .control > select').on('change',function(){var left_price=$('#bundle-summary .Left .options > div').attr('data-bundleprice')||$('#bundle-summary .Gauche .options > div').attr('data-bundleprice')||0,right_price=$('#bundle-summary .Right .options > div').attr('data-bundleprice')||$('#bundle-summary .Droit .options > div').attr('data-bundleprice')||0,leftprd_price=left_price,rightprd_price=right_price,leftOldPrice=$('.Left select').find(':selected').data("bundleprice")||0,rightOldPrice=$('.Right select').find(':selected').data("bundleprice")||0,totalprice=parseFloat(leftprd_price)+parseFloat(rightprd_price),totalOldPrice=parseFloat(leftOldPrice)+parseFloat(rightOldPrice);if(totalprice>0){$('.price-table span.prdprice').empty();$('.price-table span.prdprice').append(priceUtils.formatPrice(totalprice));$('.pricetabletotal').empty();$('.pricetabletotal').append(priceUtils.formatPrice(totalprice));if(totalOldPrice>totalprice){$('.price-table span.old-price').empty();$('.price-table span.old-price').append(priceUtils.formatPrice(totalOldPrice));}}});return false;}},EditableBundleQty:function(){var self=this,isDisabled=$('.Color .control .nested .qty').prop('disabled'),isLeftDisabled=$('.Left .control .nested .qty').prop('disabled'),isRightDisabled=$('.Right .control .nested .qty').prop('disabled');if(!isDisabled&&!isLeftDisabled&&!isRightDisabled){$('.fieldset-bundle-options .nested .qty').on('keyup',function(){var colqty=$('.Color .control > .qty').val()||0,left_qty=$('.Left .control > .qty').val()||0,right_qty=$('.Right .control > .qty').val()||0,bundleqty=$('.box-tocart #qty').val(),charger_price=self.getChargerPrice()*self.getChargerQty(),chargeprd_price,wprice=$('.extended-warranty__product select option:selected').attr('data-price')||0,chargerOldPrice=$('.field.Charger').find('.product.bundle.option').attr('data-bundleprice')||$('.field.Chargeur').find('.product.bundle.option').attr('data-bundleprice')||0,colOldPrice=$('.Color select').find(':selected').data("bundleprice")||0,leftOldPrice=$('.Left select').find(':selected').data("bundleprice")||0,rightOldPrice=$('.Right select').find(':selected').data("bundleprice")||0,col_price=$('#bundle-summary .Color .options > div').attr('data-bundleprice')||0,left_price=$('#bundle-summary .Left .options > div').attr('data-bundleprice')||$('#bundle-summary .Gauche .options > div').attr('data-bundleprice')||0,leftReceiver=$('.bundle-options-wrapper .Left.Receiver select option:selected').attr('data-product-group')||0,rightReceiver=$('.bundle-options-wrapper .Right.Receiver select option:selected').attr('data-product-group')||0,right_price=$('#bundle-summary .Right .options > div').attr('data-bundleprice')||$('#bundle-summary .Droit .options > div').attr('data-bundleprice')||0;if(leftReceiver=='ERU'){leftprd_price=0;} if(rightReceiver=='ERU'){rightprd_price=0;} if(!$('.fieldset-bundle-options '+window.CHARGER_LABEL+' .control > input.qty').length){chargeprd_price=bundleqty*charger_price;}else{chargeprd_price=charger_price;} var colprd_price=colqty*col_price,leftprd_price=left_qty*left_price,rightprd_price=right_qty*right_price,totalprice=colprd_price+leftprd_price+rightprd_price;var warqty=colqty*bundleqty,warprice=warqty*wprice,totalcolprd_price=bundleqty*colprd_price,totalleftprd_price=bundleqty*leftprd_price,totalrightprd_price=bundleqty*rightprd_price,totalprice=totalcolprd_price+totalleftprd_price+totalrightprd_price,bundleprice=totalprice+chargeprd_price;if(bundleqty==0){warprice=0;} var totalbundleprice=bundleprice+warprice;var totalOldPrice=parseFloat(colOldPrice)+parseFloat(leftOldPrice)+parseFloat(rightOldPrice)+parseFloat(chargerOldPrice);var pdpOldPrice=bundleqty*totalOldPrice;$('.price-table span.prdoldprice').empty();if(pdpOldPrice>bundleprice){$('.price-table span.prdoldprice').append(priceUtils.formatPrice(pdpOldPrice));} $('.price-table span.prdprice').empty();$('.price-table span.prdprice').append(priceUtils.formatPrice(bundleprice));$('.price-table span.warprice').empty();$('.price-table span.warprice').append(priceUtils.formatPrice(warprice));$('.pricetabletotal').empty();$('.pricetabletotal').append(priceUtils.formatPrice(totalbundleprice));if($(this).val()=='0'&&$('.bulkside').is(':checked')){$(this).attr('value',1);}});}},isPatientReferenceMandatory:function(){var requiredProductGroups=window.IS_PATIENT_REFERENCE_REQUIRED_BY_GROUP.split(",");if($.inArray(window.PRODUCT_GROUP,requiredProductGroups)==-1){return false;} return true;},EarmoldRICPriceTable:function(){var self=this;$('#addEarmold').on('click',function(){if($('.product-configurator').hasClass('active')&&$('#addEarmold').is(':checked')&&$('body').hasClass('checkout-cart-configure')){return false;} self.hideEarwears();var col_price=$('#bundle-summary .Color .options > div').attr('data-bundleprice')||0,left_price=$('#bundle-summary .Left .options > div').attr('data-bundleprice')||$('#bundle-summary .Gauche .options > div').attr('data-bundleprice')||0,right_price=$('#bundle-summary .Right .options > div').attr('data-bundleprice')||$('#bundle-summary .Droit .options > div').attr('data-bundleprice')||0,left_qty=$('.Left .control > .qty').val()||0,right_qty=$('.Right .control > .qty').val()||0,charger_price=self.getChargerPrice()*self.getChargerQty(),wprice=$('.extended-warranty__product select option:selected').attr('data-price')||0,leftReceiver=$('.bundle-options-wrapper .Left.Receiver select option:selected').attr('data-product-group')||0,rightReceiver=$('.bundle-options-wrapper .Right.Receiver select option:selected').attr('data-product-group')||0,warprice,earprice=0,bulkqty=$('.box-tocart #qty').val(),chargeprd_price=0,isMedicaidYes=self.buyingGroup().selected_medicaid_group_id||self.isPatientReferenceMandatory(),qty;chargeprd_price=charger_price;if(leftReceiver==window.RECEIVER){left_price=left_price*parseInt(window.RECEIVER_QTY);} if(rightReceiver==window.RECEIVER){right_price=right_price*parseInt(window.RECEIVER_QTY);} if(this.checked){$('#configure-button').removeClass('sr-only');$(this).addClass('showearprice');self.patientRefField.addClass('required');self.patientRefField.parent().prev().parent().addClass('required');if(left_price&&right_price&&!self.isStylettox||$('.biside').is(':checked')&&!self.isStylettox){qty=2;}else{qty=1;} if(leftReceiver=='ERU'){left_price=0;} if(rightReceiver=='ERU'){right_price=0;} var side_price=parseFloat(left_price)+parseFloat(right_price);var qtypr=qty*col_price;var prdprice=qtypr+parseFloat(side_price)+parseFloat(chargeprd_price);if(wprice){warprice=qty*wprice;}else{warprice=0;} var totalprice=prdprice+warprice+earprice;}else{self.hideEarwearsReset();$(this).removeClass('showearprice');$('#first-config .earside, #second-config .earside').addClass('cleared').removeClass('selected');$('.price-table span.earprice').attr('data-earprice','');if(leftReceiver!='ERU'&&rightReceiver!='ERU'&&!isMedicaidYes){self.patientRefField.removeClass('required');self.patientRefField.parent().prev().parent().removeClass('required');} if(left_price&&right_price&&!self.isStylettox||$('.biside').is(':checked')&&!self.isStylettox){qty=2;}else{qty=1;} if(leftReceiver=='ERU'){left_price=0;} if(rightReceiver=='ERU'){right_price=0;} var side_price=parseFloat(left_price)+parseFloat(right_price);var qtypr=qty*col_price;var prdprice=qtypr+side_price+parseFloat(chargeprd_price);if(wprice){warprice=qty*wprice;}else{warprice=0;} var totalprice=prdprice+warprice+earprice;} $('.price-table span.prdprice').empty();$('.price-table span.prdprice').append(priceUtils.formatPrice(prdprice));$('.price-table span.earprice').empty();$('.price-table span.earprice').append(priceUtils.formatPrice(earprice));$('.pricetabletotal').empty();$('.pricetabletotal').append(priceUtils.formatPrice(totalprice));if(self.isBTEBundle){var method='onEarmoldClick';self.bindBTEBundleEvents(method);} if(self.isStylettox){var method='onEarmoldClick';self.bindStylettoBundleEvents(method);}});},PricetableOnChange:function(){var self=this;$('.fieldset-bundle-options .control > select').on('change',function(){self.CheckIfDemoProduct();self.PricetableOnChangeInEdit();var colqty=$('.Color .control > .qty').val(),left_qty=$('.Left:not(.Earwear) .control > .qty').val()||0,right_qty=$('.Right:not(.Earwear) .control > .qty').val()||0,leftearwear_qty=$('.Left.Earwear .control > .qty').val()||0,rightearwear_qty=$('.Right.Earwear .control > .qty').val()||0,qty,warprice,chargeprd_price,charger_price=self.getChargerPrice()*self.getChargerQty(),col_price=$('#bundle-summary .Color .options > div').attr('data-bundleprice')||0,left_price=$('#bundle-summary .Left:not(.Earwear) .options > div').attr('data-bundleprice')||$('#bundle-summary .Gauche .options > div').attr('data-bundleprice')||0,right_price=$('#bundle-summary .Right:not(.Earwear) .options > div').attr('data-bundleprice')||$('#bundle-summary .Droit .options > div').attr('data-bundleprice')||0,leftearwear_price=$('#bundle-summary .Left.Earwear .options > div').attr('data-bundleprice')||0,rightearwear_price=$('#bundle-summary .Right.Earwear .options > div').attr('data-bundleprice')||0,chargerOldPrice=self.getChargerOldPrice(),colOldPrice=$('.Color select').find(':selected').data("bundleprice")||0,leftOldPrice=$('.Left:not(.Earwear) select').find(':selected').data("bundleprice")||0,rightOldPrice=$('.Right:not(.Earwear) select').find(':selected').data("bundleprice")||0,leftEarwearOldPrice=$('.Left.Earwear select').find(':selected').data("bundleprice")||0,rightEarwearOldPrice=$('.Right.Earwear select').find(':selected').data("bundleprice")||0,leftReceiver=$('.bundle-options-wrapper .Left:not(.Earwear) select option:selected').attr('data-product-group')||0,rightReceiver=$('.bundle-options-wrapper .Right:not(.Earwear) select option:selected').attr('data-product-group')||0,wprice=$('.extended-warranty__product select option:selected').attr('data-price')||0,colorSelected=$('.bundle-options-wrapper .Color select option:selected').attr('data-bundleprice')||0,isearmoldchecked=$('#addEarmold').is(':checked'),bulkqty=$('.box-tocart #qty').val(),isRIC=$('.bundleclass').hasClass('BTE-RICgroup'),NonHA=$('.product-add-form').hasClass('EarMoldgroup')||$('.product-add-form').hasClass('ERUgroup')||$('.product-add-form').hasClass('BTEgroupr'),isMedicaidYes=self.buyingGroup().selected_medicaid_group_id||self.isPatientReferenceMandatory(),colorNoDropdown=$('.Color > .control > div').hasClass('colornodropdown')||0;if(colqty<1||!colqty){colqty=0;} if(left_qty<1){left_qty=0;} if(right_qty<1){right_qty=0;} if(leftearwear_qty<1){leftearwear_qty=0;} if(rightearwear_qty<1){rightearwear_qty=0;} if($('.biside').is(':checked')){if(leftReceiver&&rightReceiver){$('#addEarmold').removeAttr('disabled');}else{$('#addEarmold').attr('disabled','disabled');self.hideEarwearsReset();}} if(leftReceiver=='ERU'||rightReceiver=='ERU'){self.patientRefField.addClass('required');self.patientRefField.parent().prev().parent().addClass('required');$('#configure-button').removeClass('sr-only');if(!$('.biside').is(':checked')){$('#addEarmold').attr('disabled','disabled');}} if(leftReceiver=='ERU'){$('.Left.Earwear.field select').val('');$('.Left.Earwear.field').removeClass('required');$('.Left.Earwear.field').removeClass('mage-error');$('.Left.Earwear.field select').attr('disabled','disabled');}else if(leftReceiver){$('.Left.Earwear.field select').removeAttr('disabled');if(!window.optionalEarwears){$('.Left.Earwear.field').addClass('required');}} if(rightReceiver=='ERU'){$('.Right.Earwear.field select').val('');$('.Right.Earwear.field').removeClass('required');$('.Right.Earwear.field').removeClass('mage-error');$('.Right.Earwear.field select').attr('disabled','disabled');}else if(rightReceiver){$('.Right.Earwear.field select').removeAttr('disabled');if(!window.optionalEarwears){$('.Right.Earwear.field').addClass('required');}} if($('.bulkside').is(':checked')){$('.Right.Earwear.field').removeClass('required');$('.Left.Earwear.field').removeClass('required');} if(leftReceiver!='ERU'&&rightReceiver!='ERU'&&!NonHA&&!isMedicaidYes){self.patientRefField.removeClass('required');self.patientRefField.parent().prev().parent().removeClass('required');} if(rightReceiver!='ERU'){$('#first-config .earside').attr('data-price','0');} if(leftReceiver!='ERU'){$('#second-config .earside').attr('data-price','0');} if(leftReceiver=='ERU'&&rightReceiver=='ERU'){$('#addEarmold').attr('disabled','disabled');} if($('#addEarmold').is(':checked')){self.patientRefField.addClass('required');self.patientRefField.parent().prev().parent().addClass('required');self.hideEarwears();} if(!leftReceiver&&!rightReceiver&&colorSelected&&self.isOnlyBulkOrdersSelected===false){$('.Color .control > .qty').val("1");} if(!leftReceiver&&!rightReceiver&&!colorSelected&&!colorNoDropdown){$('.Color .control > .qty').val("0");} if(left_price&&right_price&&!self.isStylettox||$('.biside').is(':checked')&&!self.isStylettox){qty=2;}else{qty=1;} if(wprice){warprice=qty*wprice;}else{warprice=0;} var colprd_price=colqty*col_price,leftprd_price=left_qty*left_price,rightprd_price=right_qty*right_price,colOldPdpPrice=colqty*colOldPrice,leftOldPdpPrice=left_qty*leftOldPrice,rightOldPdpPrice=right_qty*rightOldPrice,leftearwearprd_price=leftearwear_qty*leftearwear_price,rightearwearprd_price=rightearwear_qty*rightearwear_price,leftearwearprdOldprice=leftearwear_qty*leftEarwearOldPrice,rightearwearprdOldprice=rightearwear_qty*rightEarwearOldPrice;if(isNaN(colprd_price)){colprd_price=0;} if(isNaN(leftprd_price)){leftprd_price=0;var earprice=0;} if(isNaN(leftearwearprd_price)){leftearwearprd_price=0;} if(isNaN(rightearwearprd_price)){rightearwearprd_price=0;} if(isNaN(rightprd_price)){rightprd_price=0;var earprice=0;} if(leftReceiver=='ERU'){leftprd_price=0;} if(rightReceiver=='ERU'){rightprd_price=0;} $('.price-table span.earprice').attr('data-earprice','');$('.price-table span.earprice').empty();$('.price-table span.earprice').append(priceUtils.formatPrice(earprice));if(bulkqty==0){warprice=0;} chargeprd_price=charger_price;var totalprice=colprd_price+leftprd_price+rightprd_price+warprice+leftearwearprd_price+rightearwearprd_price,totalOldPrice=colOldPdpPrice+leftOldPdpPrice+rightOldPdpPrice+leftearwearprdOldprice+rightearwearprdOldprice+parseFloat(chargerOldPrice);totalprice=(bulkqty*totalprice)+parseFloat(charger_price);totalOldPrice=bulkqty*totalOldPrice;if(totalprice||totalprice==0){$('.price-table span.prdprice').empty();$('.price-table span.prdoldprice').empty();$('.price-table span.prdprice').append(priceUtils.formatPrice(totalprice));$('.pricetabletotal').empty();$('.pricetabletotal').append(priceUtils.formatPrice(totalprice));if(totalOldPrice>totalprice){$('.price-table span.prdoldprice').append(priceUtils.formatPrice(totalOldPrice));}} if($('.bulkside').is(':checked')){$('#addEarmold').attr('disabled','disabled');self.BulkqtyOnchangeCallback();} if(self.isBTEBundle){var method='onChange';self.bindBTEBundleEvents(method);} if(self.isStylettox){var method='onChange';self.bindStylettoBundleEvents(method);} if($('.biside').is(':checked')&&self.isStylettox){$('#addEarmold').removeAttr('disabled');}});},PricetableOnChangeInEdit:function(){var self=this,colorNoDropdown=$('.Color > .control > div').hasClass('colornodropdown')||0,leftReceiver=$('.bundle-options-wrapper .Left.Receiver select option:selected').attr('data-product-group')||0,rightReceiver=$('.bundle-options-wrapper .Right.Receiver select option:selected').attr('data-product-group')||0;if(self.iscartpage&&self.isOnlyBulkOrdersSelected===false){if($('.Left .control > select').val()==''){$('.Left .control > .qty').val("0");}else{if(leftReceiver==window.RECEIVER){$('.Left .control > .qty').val(parseInt(window.RECEIVER_QTY));}else{$('.Left .control > .qty').val("1");}} if($('.Right .control > select').val()==''){$('.Right .control > .qty').val("0");}else{if(rightReceiver==window.RECEIVER){$('.Right .control > .qty').val(parseInt(window.RECEIVER_QTY));}else{$('.Right .control > .qty').val("1");}} $('.field:not('+window.CHARGER_LABEL+') .qty-holder .qty').addClass('invisibleqty');} if($('.Right .control > select').val()!=''&&$('.Left .control > select').val()!=''&&!self.isStylettox&&!self.isBTEBundle&&(self.isOnlyBulkOrdersSelected===false)){$('.Color .control > .qty').removeAttr('disabled');$('.Color .control > .qty').addClass('invisibleqty');$('.Color .control > .qty').attr('value','2');} if(colorNoDropdown){if(($('.Right .control > select').val()==''||$('.Left .control > select').val()=='')&&(self.isOnlyBulkOrdersSelected===false)){$('.Color .control > .qty').attr('value','1');}} if($('.bulkside').is(':checked')&&self.isOnlyBulkOrdersSelected){var method='onPriceTableChangeInEdit';self.bindBulkOrderCalPrice(method);} $('#first-config .earside').addClass('cleared');$('#second-config .earside').addClass('cleared');},PricetableOnLoad:function(){var self=this,colqty=$('.Color .control > .qty').val()||0,left_qty=$('.Left .control > .qty').val()||0,right_qty=$('.Right .control > .qty').val()||0,qty,warprice,bulkqty=$('.box-tocart #qty').val(),charger_price=self.getChargerPrice()*self.getChargerQty(),left_price=$('#bundle-summary .Left .options > div').attr('data-bundleprice')||$('#bundle-summary .Gauche .options > div').attr('data-bundleprice')||0,right_price=$('#bundle-summary .Right .options > div').attr('data-bundleprice')||$('#bundle-summary .Droit .options > div').attr('data-bundleprice')||0,leftOldPrice=$('.Left select').find(':selected').data("bundleprice")||0,rightOldPrice=$('.Right select').find(':selected').data("bundleprice")||0,leftReceiver=$('.bundle-options-wrapper .Left.Receiver select option:selected').attr('data-product-group')||0,rightReceiver=$('.bundle-options-wrapper .Right.Receiver select option:selected').attr('data-product-group')||0,wprice=$('.extended-warranty__product select option:selected').attr('data-price')||0,color_selected_price=$('#bundle-summary .Color .options > div').attr('data-bundleprice')||0,NonHA=$('.product-add-form').hasClass('EarMoldgroup')||$('.product-add-form').hasClass('ERUgroup')||$('.product-add-form').hasClass('BTEgroupr'),isMedicaidYes=self.buyingGroup().selected_medicaid_group_id||self.isPatientReferenceMandatory();if(self.iscartpage){if(left_qty<1){left_qty=0;} if(right_qty<1){right_qty=0;} if(leftReceiver=='ERU'||rightReceiver=='ERU'){self.patientRefField.addClass('required');self.patientRefField.parent().prev().parent().addClass('required');$('#configure-button').removeClass('sr-only');}else{if(!isMedicaidYes&&!NonHA){self.patientRefField.removeClass('required');self.patientRefField.parent().prev().parent().removeClass('required');}} if(leftReceiver=='ERU'&&rightReceiver=='ERU'){$('#addEarmold').attr('disabled','disabled');} if(left_price&&right_price&&!self.isStylettox){qty=2;}else{qty=1;} if(wprice){warprice=qty*wprice;}else{warprice=0;} var color_product_price=color_selected_price*colqty,leftprd_price=left_qty*left_price,rightprd_price=right_qty*right_price,leftOldPdpPrice=left_qty*leftOldPrice,rightOldPdpPrice=right_qty*rightOldPrice;if(isNaN(leftprd_price)){leftprd_price=0;var earprice=0;} if(isNaN(rightprd_price)){rightprd_price=0;var earprice=0;} if(leftReceiver=='ERU'){leftprd_price=0;} if(rightReceiver=='ERU'){rightprd_price=0;} var totalprice=color_product_price+leftprd_price+rightprd_price+warprice+charger_price,totalOldPrice=leftOldPdpPrice+rightOldPdpPrice,totalprice=bulkqty*totalprice,pdpOldPrice=bulkqty*pdpOldPrice;if(totalprice||totalprice==0){$('.price-table span.prdprice').empty();$('.price-table span.prdoldprice').empty();$('.price-table span.prdprice').append(priceUtils.formatPrice(totalprice));$('.pricetabletotal').empty();$('.pricetabletotal').append(priceUtils.formatPrice(totalprice));if(pdpOldPrice>totalprice){$('.price-table span.prdoldprice').append(priceUtils.formatPrice(pdpOldPrice));}}} if(!self.iscartpage){if(left_qty<1){left_qty=0;} if(right_qty<1){right_qty=0;} if(left_qty&&right_qty&&!self.isStylettox){qty=2;}else{qty=1;} if(wprice){warprice=qty*wprice;}else{warprice=0;} var color_product_price=color_selected_price*colqty,left_prd_price=left_qty*left_price,right_prd_price=right_qty*right_price;var total_product_price=color_product_price+left_prd_price+right_prd_price+warprice,total_price=charger_price+(bulkqty*total_product_price),pdp_OldPrice=bulkqty*pdpOldPrice;if(total_price||total_price==0){$('.price-table span.prdprice').empty();$('.price-table span.prdoldprice').empty();$('.price-table span.prdprice').append(priceUtils.formatPrice(total_price));$('.pricetabletotal').empty();$('.pricetabletotal').append(priceUtils.formatPrice(total_price));if(pdp_OldPrice>total_price){$('.price-table span.prdoldprice').append(priceUtils.formatPrice(pdp_OldPrice));}}}},CheckIfDemoProduct:function(){var leftReceiver=$('.bundle-options-wrapper .Left.Receiver select option:selected').attr('data-product-group')||0,rightReceiver=$('.bundle-options-wrapper .Right.Receiver select option:selected').attr('data-product-group')||0,left_qty=$('.Left .control > .qty').val()||0,right_qty=$('.Right .control > .qty').val()||0;if($('.product-add-form').hasClass('demoproduct')){if(leftReceiver){$('.Left .qty-holder .qty').removeAttr('disabled');$('.Left .qty-holder .qty').removeClass('invisibleqty');}else{$('.Left .qty-holder .qty').attr('disabled');} if(leftReceiver&&left_qty==0){$('.Left .qty-holder .qty').val('1');} if(rightReceiver){$('.Right .qty-holder .qty').removeAttr('disabled');$('.Right .qty-holder .qty').removeClass('invisibleqty');}else{$('.Right .qty-holder .qty').attr('disabled');} if(rightReceiver&&right_qty==0){$('.Right .qty-holder .qty').val('1');}}},RadioSelectors:function(){var leftReceiver=$('.bundle-options-wrapper .Left.Receiver select option:selected').attr('data-product-group')||0,rightReceiver=$('.bundle-options-wrapper .Right.Receiver select option:selected').attr('data-product-group')||0,colorNoDropdown=$('.Color > .control > div').hasClass('colornodropdown')||0,isDemoProduct=$('.Color > .control > div').hasClass('isdemoproduct')||0,self=this;if($('.biside').is(':checked')){if(!self.iscartpage){$('.Right.field').addClass('required');$('.Left.field').addClass('required');$('.Right.field select').addClass('required');$('.Left.field select').addClass('required');$('.radioselector').removeClass('isnotbinaural');if(window.optionalEarwears){$('.Right.Earwear.field').removeClass('required');$('.Right.Earwear.field').removeClass('required');$('.Right.Earwear.field select').removeClass('required');$('.Right.Earwear.field select').removeClass('required');} $('.box-tocart .qty').prop('disabled',true);} if(self.iscartpage){$('.box-tocart #qty').addClass('invisibleqty');}} if(this.hasLndProductSku==true||this.sideRestriction=='Binaural'){$('.box-tocart #qty').val('1');if($('.rightside').is(':checked')){$('.Right.field').addClass('required');$('.Right.field select').addClass('required');$('.Left.field').removeClass('required');$('.Left.field select').removeClass('required');$('.Left.field select').attr('disabled','disabled');$('.Right.field select').removeAttr('disabled');$('.radioselector').addClass('isnotbinaural');$('.Left.Earwear.field select').val('');$('.Left.Earwear.field').removeClass('required');$('.Left.Earwear.field select').attr('disabled','disabled');self.resetValidationError();} if($('.leftside').is(':checked')){$('.Left.field').addClass('required');$('.Left.field select').addClass('required');$('.Right.field').removeClass('required');$('.Right.field select').removeClass('required');$('.Right.field select').attr('disabled','disabled');$('.Left.field select').removeAttr('disabled');$('.Right.Earwear.field select').val('');$('.Right.Earwear.field').removeClass('required');$('.Right.Earwear.field select').attr('disabled','disabled');$('.radioselector').addClass('isnotbinaural');self.resetValidationError();}} $('.radioselector .custom-radio > .radio').on('click',function(){if(this.checked){if($(this).hasClass('biside')){$('.Right.field').addClass('required');$('.Left.field').addClass('required');$('.Right.field select').addClass('required');$('.Left.field select').addClass('required');$('.Left.field select').removeAttr('disabled');$('.Right.field select').removeAttr('disabled');$('.radioselector').removeClass('isnotbinaural');if(window.optionalEarwears){$('.Left.Earwear.field').removeClass('required');$('.Right.Earwear.field').removeClass('required');$('.Left.Earwear.field select').removeClass('required');$('.Right.Earwear.field select').removeClass('required');} self.resetValidationError();} if($(this).hasClass('rightside')){$('.Right.field').addClass('required');$('.Right.field select').addClass('required');$('.Left.field').removeClass('required');$('.Left.field select').removeClass('required');$('.Left.field select').attr('disabled','disabled');$('.Right.field select').removeAttr('disabled');$('.Left.Earwear.field select').val('');$('.Left.Earwear.field').removeClass('required');$('.Left.Earwear.field select').attr('disabled','disabled');$('.radioselector').addClass('isnotbinaural');$('.Right.Earwear.field select').removeAttr('disabled');self.resetValidationError();if(window.optionalEarwears){$('.Right.Earwear.field').removeClass('required');$('.Right.Earwear.field select').removeClass('required');}} if($(this).hasClass('leftside')){$('.Left.field').addClass('required');$('.Left.field select').addClass('required');$('.Right.field').removeClass('required');$('.Right.field select').removeClass('required');$('.Right.field select').attr('disabled','disabled');$('.Left.field select').removeAttr('disabled');$('.Right.Earwear.field select').val('');$('.Right.Earwear.field').removeClass('required');$('.Right.Earwear.field select').attr('disabled','disabled');$('.radioselector').addClass('isnotbinaural');$('.Left.Earwear.field select').removeAttr('disabled');self.resetValidationError();if(window.optionalEarwears){$('.Left.Earwear.field').removeClass('required');$('.Left.Earwear.field select').removeClass('required');}} if($(this).hasClass('bulkside')){$('.Left.field').removeClass('required');$('.Left.field select').removeClass('required');$('.Right.field').removeClass('required');$('.Right.field select').removeClass('required');$('.Left.field select').removeAttr('disabled');$('.Right.field select').removeAttr('disabled');$('.Right.Earwear.field').removeClass('required');$('.Left.Earwear.field').removeClass('required');$('#addEarmold').prop('checked',false);$('#addEarmold').attr('disabled','disabled');$('.radioselector > .control').addClass('isnotbinaural');$('.Right.field select').find('option[data-product-group="ERU"]').attr('disabled','disabled');$('.Left.field select').find('option[data-product-group="ERU"]').attr('disabled','disabled');$('.box-tocart .qty').prop('disabled',false);if(self.iscartpage){$('.box-tocart #qty').removeClass('invisibleqty');} if($('.bulkside').is(':checked')&&self.isOnlyBulkOrdersSelected){var method='onRadioSelector';self.bindBulkOrderCalPrice(method);}else{$('.Color .control > .qty').attr('value','2');} self.resetValidationError();}else{if(!self.iscartpage){$('.box-tocart .qty').prop('disabled',true);} if(self.iscartpage){$('.box-tocart #qty').addClass('invisibleqty');} $('.box-tocart .qty').val('1');$('.Right.field select').find('option[data-product-group="ERU"]').removeAttr('disabled');$('.Left.field select').find('option[data-product-group="ERU"]').removeAttr('disabled');} $('.fieldset-bundle-options .field:not('+window.CHARGER_LABEL+') .control > select').prop('selectedIndex',0);$('.fieldset-bundle-options .field:not('+window.CHARGER_LABEL+') .control > select').trigger('change');if($(this).hasClass('leftside')){$('.Left.field select').removeAttr('disabled');$('.Left.field').addClass('required');if(window.optionalEarwears){$('.Left.Earwear.field').removeClass('required');}} if($(this).hasClass('rightside')){$('.Right.field select').removeAttr('disabled');$('.Right.field').addClass('required');if(window.optionalEarwears){$('.Right.Earwear.field').removeClass('required');}} if(!colorNoDropdown){$('.Color .control > .qty').val("0");}} self.ResetPriceTable();if(self.isBTEBundle){var method='onRadioSelector';self.bindBTEBundleEvents(method);self.BulkqtyOnchangeCallback();} if(self.isStylettox){var method='onRadioSelector';self.bindStylettoBundleEvents(method);}});},ResetPriceTable:function(){var self=this,resetprice=0,prdprice=0,totalprice,charger_price=self.getChargerPrice()*self.getChargerQty(),warprice=$('.extended-warranty__product select option:selected').attr('data-price')||0,isSingleColorOption=$('.Color > .control > div').hasClass('colornodropdown')||0,chargerOldPrice=$('.field.Charger').find('.product.bundle.option').attr('data-bundleprice')||$('.field.Chargeur').find('.product.bundle.option').attr('data-bundleprice')||0;if(charger_price){prdprice=charger_price;totalprice=parseFloat(charger_price)+parseFloat(warprice);} if(isSingleColorOption){var color_qty=$('.Color .control > .qty').val(),color_price=$('.Color .price-notice .price-container > span').attr('data-price-amount')||0,colprd_price=color_qty*color_price,single_charger_price=$('.Charger .price-notice .price-container > span').attr('data-price-amount')||0;single_charger_price?single_charger_price:charger_price;prdprice=parseFloat(colprd_price)+parseFloat(single_charger_price);} totalprice=parseFloat(prdprice)+parseFloat(warprice);$('.price-table span.prdprice').empty();$('.price-table span.prdprice').append(priceUtils.formatPrice(prdprice));$('.price-table span.warprice').empty();$('.price-table span.warprice').append(priceUtils.formatPrice(warprice));$('.price-table span.earprice').empty();$('.price-table span.earprice').append(priceUtils.formatPrice(resetprice));$('.pricetabletotal').empty();$('.pricetabletotal').append(priceUtils.formatPrice(totalprice));},resetValidationError:function(){$('.Color select').removeClass('mage-error');$('.Color .control div.mage-error').remove();$('.Left select').removeClass('mage-error');$('.Left .control div.mage-error').remove();$('.Right select').removeClass('mage-error');$('.Right .control div.mage-error').remove();},BulkQtyOnChange:function(){var self=this;$('.bundle-options-container .box-tocart .qty').on('keyup',function(){var bundleqty=$(this).val(),col_price=$('#bundle-summary .Color .options > div').attr('data-bundleprice')||0,left_price=$('#bundle-summary .Left:not(.Earwear) .options > div').attr('data-bundleprice')||$('#bundle-summary .Gauche .options > div').attr('data-bundleprice')||0,right_price=$('#bundle-summary .Right:not(.Earwear) .options > div').attr('data-bundleprice')||$('#bundle-summary .Droit .options > div').attr('data-bundleprice')||0,leftearwear_price=$('#bundle-summary .Left.Earwear .options > div').attr('data-bundleprice')||0,rightearwear_price=$('#bundle-summary .Right.Earwear .options > div').attr('data-bundleprice')||0,charger_price=self.getChargerPrice()*self.getChargerQty(),chargerOldPrice=$('.field.Charger').find('.product.bundle.option').attr('data-bundleprice')||$('.field.Chargeur').find('.product.bundle.option').attr('data-bundleprice')||0,colOldPrice=$('.Color select').find(':selected').data("bundleprice")||0,leftOldPrice=$('.Left:not(.Earwear) select').find(':selected').data("bundleprice")||0,rightOldPrice=$('.Right:not(.Earwear) select').find(':selected').data("bundleprice")||0,leftEarwearOldPrice=$('.Left.Earwear select').find(':selected').data("bundleprice")||0,rightEarwearOldPrice=$('.Right.Earwear select').find(':selected').data("bundleprice")||0,wprice=$('.extended-warranty__product select option:selected').attr('data-price')||0,colsideqty=$('.Color.field .nested .control .qty').val()||0,leftsideqty=$('.Left:not(.Earwear) .nested .control .qty').val()||0,rightsideqty=$('.Right:not(.Earwear) .nested .control .qty').val()||0,leftearwearqty=$('.Left.Earwear .nested .control .qty').val()||0,rightearwearqty=$('.Right.Earwear .nested .control .qty').val()||0,colprd_price=colsideqty*col_price,leftprd_price=leftsideqty*left_price,rightprd_price=rightsideqty*right_price,leftEarprd_price=leftearwearqty*leftearwear_price,rightEarprd_price=rightearwearqty*rightearwear_price,chargeprd_price,totalsideqty=parseInt(leftsideqty)+parseInt(rightsideqty),totalearwearqty=parseInt(leftearwearqty)+parseInt(rightearwearqty),chargeprd_price=charger_price;if(totalsideqty=='0'&&colsideqty=='0'||totalsideqty=='0'&&colsideqty=='1'){totalsideqty=1} var warqty=totalsideqty*bundleqty;var warprice=warqty*wprice,totalcolprd_price=bundleqty*colprd_price,totalleftprd_price=bundleqty*leftprd_price,totalrightprd_price=bundleqty*rightprd_price,totalleftearprd_price=bundleqty*leftEarprd_price,totalrightearprd_price=bundleqty*rightEarprd_price,totalprice=totalcolprd_price+totalleftprd_price+totalrightprd_price+totalleftearprd_price+totalrightearprd_price,bundleprdprice=chargeprd_price+colprd_price+leftprd_price+rightprd_price,bundleprice=totalprice+chargeprd_price,totalbundleprice=bundleprice+warprice;var totalOldPrice=parseFloat(colOldPrice)+parseFloat(leftOldPrice)+parseFloat(rightOldPrice)+parseFloat(chargerOldPrice)+parseFloat(leftEarwearOldPrice)+parseFloat(rightEarwearOldPrice);var pdpOldPrice=bundleqty*totalOldPrice;$('.price-table span.prdoldprice').empty();if(pdpOldPrice>bundleprice){$('.price-table span.prdoldprice').append(priceUtils.formatPrice(pdpOldPrice));} $('.price-table span.prdprice').empty();$('.price-table span.prdprice').append(priceUtils.formatPrice(bundleprice));$('.price-table span.warprice').empty();$('.price-table span.warprice').append(priceUtils.formatPrice(warprice));$('.pricetabletotal').empty();$('.pricetabletotal').append(priceUtils.formatPrice(totalbundleprice));return false;});},getChargerQty:function(){var self=this,charger_qty=0,bulkqty=$('.box-tocart #qty').val(),charger_control;if($('.fieldset-bundle-options '+window.CHARGER_LABEL+' input.qty').length){charger_control=$('.fieldset-bundle-options '+window.CHARGER_LABEL+' input.qty');charger_qty=charger_control.val()*bulkqty;} if(!$('.fieldset-bundle-options '+window.CHARGER_LABEL+' .control > select').length&&$('.fieldset-bundle-options '+window.CHARGER_LABEL+' input[type="checkbox"]').is(':checked')){charger_qty=bulkqty;} if($('.fieldset-bundle-options '+window.CHARGER_LABEL).hasClass('required')&&!$('.fieldset-bundle-options '+window.CHARGER_LABEL+' input.qty').length&&!$('.fieldset-bundle-options '+window.CHARGER_LABEL+' .control > select').length){charger_qty=bulkqty;} return charger_qty;},ChargerCheckbox:function(){var self=this,charger_control;if(!$('.fieldset-bundle-options '+window.CHARGER_LABEL+' .control > input.qty').length){if($('.fieldset-bundle-options '+window.CHARGER_LABEL+' input').length){charger_control=$('.fieldset-bundle-options '+window.CHARGER_LABEL+' input');} if(charger_control){charger_control.on('change',function(){self.BulkqtyOnchangeCallback();});}}},chargerQtyBox:function(){var self=this,charger_control;if($('.fieldset-bundle-options '+window.CHARGER_LABEL+' .control > select').length){charger_control=$('.fieldset-bundle-options '+window.CHARGER_LABEL+' input');if(!$('.fieldset-bundle-options '+window.CHARGER_LABEL).hasClass('required')){charger_control.removeAttr('disabled').removeClass('invisibleqty');if(charger_control.length){charger_control.on('keyup',function(){self.BulkqtyOnchangeCallback();});}}else{charger_control.attr('disabled','disabled').addClass('invisibleqty');}}},BulkqtyOnchangeCallback:function(){var self=this,isSingleColorOption=$('.Color > .control > div').hasClass('colornodropdown')||0,bundleqty=$('.box-tocart #qty').val(),leftReceiver=$('.bundle-options-wrapper .Left.Receiver select option:selected').attr('data-product-group')||0,rightReceiver=$('.bundle-options-wrapper .Right.Receiver select option:selected').attr('data-product-group')||0,col_price=$('#bundle-summary .Color .options > div').attr('data-bundleprice')||0,left_price=$('#bundle-summary .Left:not(.Earwear) .options > div').attr('data-bundleprice')||$('#bundle-summary .Gauche .options > div').attr('data-bundleprice')||0,right_price=$('#bundle-summary .Right:not(.Earwear) .options > div').attr('data-bundleprice')||$('#bundle-summary .Droit .options > div').attr('data-bundleprice')||0,leftearwear_price=$('#bundle-summary .Left.Earwear .options > div').attr('data-bundleprice')||0,rightearwear_price=$('#bundle-summary .Right.Earwear .options > div').attr('data-bundleprice')||0,single_charger_price=$('.Charger .price-notice .price-container > span').attr('data-price-amount')||0,charger_price=self.getChargerPrice()*self.getChargerQty(),chargerOldPrice=self.getChargerOldPrice(),colOldPrice=$('.Color select').find(':selected').data("bundleprice")||0,leftOldPrice=$('.Left:not(.Earwear) select').find(':selected').data("bundleprice")||0,rightOldPrice=$('.Right:not(.Earwear) select').find(':selected').data("bundleprice")||0,leftEarwearOldPrice=$('.Left.Earwear select').find(':selected').data("bundleprice")||0,rightEarwearOldPrice=$('.Right.Earwear select').find(':selected').data("bundleprice")||0,wprice=$('.extended-warranty__product select option:selected').attr('data-price')||0,colsideqty=$('.Color.field .nested .control .qty').val()||0,leftsideqty=$('.Left:not(.Earwear) .nested .control .qty').val()||0,rightsideqty=$('.Right:not(.Earwear) .nested .control .qty').val()||0,leftEarwearqty=$('.Left.Earwear .nested .control .qty').val()||0,rightEarwearqty=$('.Right.Earwear .nested .control .qty').val()||0,colprd_price=colsideqty*col_price;if(leftReceiver=='ERU'){left_price=0;} if(rightReceiver=='ERU'){right_price=0;} var r_earprice=$('#first-config .earside').attr('data-price')||0,l_earprice=$('#second-config .earside').attr('data-price')||0,earprice=parseFloat(r_earprice)+parseFloat(l_earprice),leftprd_price=leftsideqty*left_price,rightprd_price=rightsideqty*right_price,leftearwearprd_price=leftEarwearqty*leftearwear_price,rightearwearprd_price=rightEarwearqty*rightearwear_price;if(isSingleColorOption){var color_qty=$('.Color .control > .qty').val(),color_price=$('.Color .price-notice .price-container > span').attr('data-price-amount');} var warqty=colsideqty*bundleqty,warprice=warqty*wprice,totalcolprd_price=bundleqty*colprd_price,totalleftprd_price=bundleqty*leftprd_price,totalrightprd_price=bundleqty*rightprd_price,totalleftEarprd_price=bundleqty*leftearwearprd_price,totalrightEarprd_price=bundleqty*rightearwearprd_price,totalprice=totalcolprd_price+totalleftprd_price+totalrightprd_price+totalleftEarprd_price+totalrightEarprd_price,bundleprice=totalprice+charger_price;if(bundleqty==0){warprice=0;} var totalbundleprice=bundleprice+earprice+warprice;var totalOldPrice=parseFloat(colOldPrice)+parseFloat(leftOldPrice)+parseFloat(rightOldPrice)+parseFloat(chargerOldPrice)+parseFloat(leftEarwearOldPrice)+parseFloat(rightEarwearOldPrice);var pdpOldPrice=bundleqty*totalOldPrice;$('.price-table span.prdoldprice').empty();if(pdpOldPrice>bundleprice){$('.price-table span.prdoldprice').append(priceUtils.formatPrice(pdpOldPrice));} if(earprice){$('.price-table span.earprice').empty();$('.price-table span.earprice').append(priceUtils.formatPrice(earprice));} $('.price-table span.earprice').attr('data-earprice',earprice);$('.price-table span.prdprice').empty();$('.price-table span.prdprice').append(priceUtils.formatPrice(bundleprice));$('.price-table span.warprice').empty();$('.price-table span.warprice').append(priceUtils.formatPrice(warprice));$('.pricetabletotal').empty();$('.pricetabletotal').append(priceUtils.formatPrice(totalbundleprice));return false;},OptionSelectedInBundleEdit:function(custom_selection){var self=this,rightval=$('.Right.field select').val()||0,leftval=$('.Left.field select').val()||0,earmoldval,leftReceiver=$('.bundle-options-wrapper .Left.Receiver select option:selected').attr('data-product-group')||0,rightReceiver=$('.bundle-options-wrapper .Right.Receiver select option:selected').attr('data-product-group')||0,bulkqty=$('.box-tocart #qty').val();if(window.isChargerSelected){$('.bundle-options-wrapper .Charger .control input, .bundle-options-wrapper .Chargeur .control input').prop('checked',true);$('.bundle-options-wrapper .Charger .control input, .bundle-options-wrapper .Chargeur .control input').trigger('change');} if(self.iscartpage&&($('.product-add-form').hasClass('EarMoldgroup')||$('.product-add-form').hasClass('BTE-RICgroup')||self.isBTEBundle||self.isStylettox||self.isStockBundle||self.isOnlyBulkOrdersSelected)){if(leftReceiver=='ERU'||rightReceiver=='ERU'){self.patientRefField.addClass('required');self.patientRefField.parent().prev().parent().addClass('required');} if(custom_selection==self.BinauralSelected){$('.biside').prop('checked',true);$('.Right.field').addClass('required');$('.Right.field select').addClass('required');$('.Left.field').addClass('required');$('.Left.field select').addClass('required');$('.box-tocart #qty').addClass('invisibleqty');if($('.product-add-form').hasClass('onlyPatientBased')){$('.radio.biside').trigger('click');}}else{self.isBulkCheckedinEdit();self.BulkqtyOnchangeCallback();} if(custom_selection==self.RightSelected){$('.rightside').prop('checked',true);$('.Left.field').removeClass('required');$('.Left.field select').removeClass('required');$('.Left.field select').attr('disabled','disabled');$('.Right.field').addClass('required');$('.Right.field select').addClass('required');$('.Right.field select').removeAttr('disabled');$('.radioselector').addClass('isnotbinaural');$('.Right.field select').find('option[data-product-group="ERU"]').removeAttr('disabled');$('.Left.field select').find('option[data-product-group="ERU"]').removeAttr('disabled');$('.box-tocart #qty').addClass('invisibleqty');if(rightReceiver!='ERU'){$('#addEarmold').removeAttr('disabled');}} if(custom_selection==self.LeftSelected){$('.leftside').prop('checked',true);$('.Right.field').removeClass('required');$('.Right.field select').removeClass('required');$('.Right.field select').attr('disabled','disabled');$('.Left.field').addClass('required');$('.Left.field select').addClass('required');$('.Left.field select').removeAttr('disabled');$('.radioselector').addClass('isnotbinaural');$('.Right.field select').find('option[data-product-group="ERU"]').removeAttr('disabled');$('.Left.field select').find('option[data-product-group="ERU"]').removeAttr('disabled');$('.box-tocart #qty').addClass('invisibleqty');if(leftReceiver!='ERU'){$('#addEarmold').removeAttr('disabled');}} if(custom_selection==self.BulkSelected){self.isBulkCheckedinEdit();self.BulkqtyOnchangeCallback();} if(self.isBTEBundle&&$('.biside').is(':checked')){$('.Color .control > .qty').attr('value','2');self.BulkqtyOnchangeCallback();}else{if(!$('.bulkside').is(':checked')&&!self.iscartpage&&self.isOnlyBulkOrdersSelected===false){$('.Color .control > .qty').attr('value','1');}}}},isBulkCheckedinEdit:function(){var self=this;$('.bulkside').prop('checked',true);$('.Left.field').removeClass('required');$('.Left.field select').removeClass('required');$('.Right.field').removeClass('required');$('.Right.field select').removeClass('required');$('.box-tocart #qty').removeAttr('disabled');$('.Right.field select').removeAttr('disabled');$('.Left.field select').removeAttr('disabled');$('.box-tocart #qty').removeClass('invisibleqty');$('#addEarmold').attr('disabled','disabled');$('.Right.field select').find('option[data-product-group="ERU"]').attr('disabled','disabled');$('.Left.field select').find('option[data-product-group="ERU"]').attr('disabled','disabled');if(self.isOnlyBulkOrdersSelected){var method='isBulkCheckedinEdit';self.bindBulkOrderCalPrice(method);}},bindBTEBundleEvents:function(method){var self=this,leftReceiverExist=$('.bundle-options-wrapper .Left.Receiver select').length,rightReceiverExist=$('.bundle-options-wrapper .Right.Receiver select').length,leftReceiver=$('.bundle-options-wrapper .Left.Receiver select option:selected').attr('data-product-group')||0,isMedicaidYes=self.buyingGroup().selected_medicaid_group_id||self.isPatientReferenceMandatory(),rightReceiver=$('.bundle-options-wrapper .Right.Receiver select option:selected').attr('data-product-group')||0,colorNoDropdown=$('.Color > .control > div').hasClass('colornodropdown')||0,isReceiverExist=leftReceiverExist&&rightReceiverExist;if(self.isBTEBundle){switch(method){case'onChange':if($('.biside').is(':checked')&&!isReceiverExist||isReceiverExist&&leftReceiver&&rightReceiver){$('.Color .control > .qty').val("2");} if($('.biside').is(':checked')){self.qty=2;}else{self.qty=1;} if(!$('.bulkside').is(':checked')&&!isReceiverExist){$('#addEarmold').removeAttr('disabled');} if(self.wprice){self.warprice=self.qty*self.wprice;}else{self.warprice=0;} if(self.bulkqty==0){self.warprice=0;} if(window.onlyBulkOrders){$('.Color .nested .control .input-text.qty').removeClass('qty-disabled');$('.Color .nested .control .input-text.qty').removeAttr('disabled');$('.Color .nested .control .input-text.qty').removeClass('invisibleqty');} break;case'onEarmoldClick':if(!$('#addEarmold').is(':checked')){$('.box-tocart .actions').removeClass('sr-only');$('#configure-button').addClass('hide');} break;case'onRadioSelector':if($('.bulkside').is(':checked')){$('.box-tocart .actions').removeClass('sr-only');$('#configure-button').addClass('hide');if(!isMedicaidYes){self.patientRefField.removeClass('required');self.patientRefField.parent().prev().parent().removeClass('required');}} if(colorNoDropdown&&self.isOnlyBulkOrdersSelected===false){if(!$('.biside').is(':checked')){$('.Color .control > .qty').attr('value','1');}else{$('.Color .control > .qty').attr('value','2');}} break;default:if($('.biside').is(':checked')&&!self.iscartpage){$('.Color .control > .qty').val('0');} if(window.onlyBulkOrders){$('.box-tocart #qty').addClass('invisibleqty');$('.Color .nested').css('opacity',1);$('.Color .nested > .field.qty').removeClass('sr-only');$('.Color .nested .control .input-text.qty').removeClass('qty-disabled');$('.Color .nested .control .input-text.qty').removeClass('invisibleqty');$('.Color .nested .control .input-text.qty').removeAttr('disabled');} if(colorNoDropdown&&self.isOnlyBulkOrdersSelected===false){$('.Color .control > .qty').addClass('invisibleqty');if(!self.iscartpage){$('.Color .control > .qty').attr('value','2');}} break;}}},bindStylettoBundleEvents:function(method){var self=this,isMedicaidYes=self.buyingGroup().selected_medicaid_group_id||self.isPatientReferenceMandatory();if(self.isStylettox){switch(method){case'onRadioSelector':if($('.bulkside').is(':checked')){$('.box-tocart .actions').removeClass('sr-only');$('#configure-button').addClass('hide');if(!isMedicaidYes){self.patientRefField.removeClass('required');self.patientRefField.parent().prev().parent().removeClass('required');}}else{$('#addEarmold').removeAttr('disabled');} break;case'onEarmoldClick':if(!$('#addEarmold').is(':checked')){$('.box-tocart .actions').removeClass('sr-only');$('#configure-button').addClass('hide');} break;case'onChange':if(window.onlyBulkOrders){$('.Color .nested .control .input-text.qty').removeClass('qty-disabled');$('.Color .nested .control .input-text.qty').removeAttr('disabled');} break;default:$('.l_side').remove();$('.r_side').remove();self.getBinauraltext=$t('Single Set');if(!self.iscartpage){$('.biside').prop('checked',true);} if(window.onlyBulkOrders){$('.box-tocart #qty').addClass('invisibleqty');$('.Color .nested').css('opacity',1);$('.Color .nested .field.qty').removeClass('sr-only');$('.Color .nested .control .input-text.qty').removeClass('qty-disabled');$('.Color .nested .control .input-text.qty').removeClass('invisibleqty');$('.Color .nested .control .input-text.qty').removeAttr('disabled');} break;}}},bindBulkOrderCalPrice:function(method){var self=this;if(self.isOnlyBulkOrdersSelected===true){switch(method){case'onPriceTableChangeInEdit':$('.Color .control .qty-holder').removeClass('invisible');$('.Color .control > .qty').removeAttr('disabled');$('.Color .control > .qty').removeClass('invisibleqty');$('.Color .control > .qty').removeClass('qty-disabled');$('.Left .control > .qty').removeAttr('disabled');$('.Left .control > .qty').removeClass('invisibleqty');$('.Left .control > .qty').removeClass('qty-disabled');$('.Right .control > .qty').removeAttr('disabled');$('.Right .control > .qty').removeClass('invisibleqty');$('.Right .control > .qty').removeClass('qty-disabled');break;case'onRadioSelector':$('.Color .control .qty-holder').removeClass('invisible');$('.Color .control > .qty').removeAttr('disabled').removeClass('invisibleqty').removeClass('qty-disabled');if(window.onlyBulkOrders){$('.Left .control > .qty').removeAttr('disabled').removeClass('invisibleqty').removeClass('qty-disabled');$('.Right .control > .qty').removeAttr('disabled').removeClass('invisibleqty').removeClass('qty-disabled');} break;case'isBulkCheckedinEdit':$('.Color .control .qty-holder').removeClass('invisible');$('.Color .control > .qty').removeAttr('disabled');$('.Color .control > .qty').removeClass('invisibleqty');$('.Color .control > .qty').removeClass('qty-disabled');$('.Left .control > .qty').removeAttr('disabled');$('.Left .control > .qty').removeClass('invisibleqty');$('.Left .control > .qty').removeClass('qty-disabled');$('.Right .control > .qty').removeAttr('disabled');$('.Right .control > .qty').removeClass('invisibleqty');$('.Right .control > .qty').removeClass('qty-disabled');break;default:$('.Color .control > .qty, .Left .control > .qty, .Right .control > .qty').on('keyup',function(){self.BulkqtyOnchangeCallback();return false;});if(self.getShowPkgQty=='1'){$('.box-tocart .field.qty').removeClass('invisible');} break;}}},triggerEarMold:function(){var self=this;if(self.iscartpage&&window.earmoldCheck===false){window.earmoldCheck=true;var pageUrl=$(location).attr('href'),quoteItemUrl=pageUrl.split('id/'),quoteItemArray=quoteItemUrl[1].split('/'),quoteItemId=quoteItemArray[0];$.ajax({type:"GET",url:window.BASE_URL+'/pcm/earmoldcheck/index',data:{'quote_item_id':quoteItemId},dataType:'json',success:function(data){if(data.success==1){var earmoldval=data.count;if($('.product-add-form').hasClass('onlyBuklOrders')){data.count=0;} if(data.count>0){$('#addEarmold').trigger('click');$("#addEarmold").attr("checked","checked");$("#configure-button").removeClass("hide");$("#configure-button").removeClass("sr-only");$("#product-updatecart-button").parent().addClass('sr-only');$('#configure-button').trigger('click');}else{if(!$('#configure-button').hasClass('hide')){$('#configure-button').trigger('click');}}} $('#warranty-config').removeClass('cart-edit-loader');},error:function(xhr,textStatus,errorThrown){console.log(textStatus);}});}},hideEarwears:function(){$('.Right.Earwear.field select').val('');$('.Left.Earwear.field select').val('');$('.Right.Earwear.field').removeClass('required');$('.Right.Earwear.field select').attr('disabled','disabled');$('.Left.Earwear.field').removeClass('required');$('.Left.Earwear.field select').attr('disabled','disabled');},hideEarwearsReset:function(){var leftReceiver=$('.bundle-options-wrapper .Left:not(.Earwear) select option:selected').attr('data-product-group')||0;var rightReceiver=$('.bundle-options-wrapper .Right:not(.Earwear) select option:selected').attr('data-product-group')||0;if($('.rightside').is(':checked')){$('.Right.Earwear.field select').removeAttr('disabled');if(!window.optionalEarwears){$('.Right.Earwear.field').addClass('required');}} if($('.leftside').is(':checked')){$('.Left.Earwear.field select').removeAttr('disabled');if(!window.optionalEarwears){$('.Left.Earwear.field').addClass('required');}} if($('.biside').is(':checked')){$('.Right.Earwear.field select').removeAttr('disabled');$('.Left.Earwear.field select').removeAttr('disabled');if(!window.optionalEarwears){$('.Right.Earwear.field').addClass('required');$('.Left.Earwear.field').addClass('required');}} if(leftReceiver=='ERU'){$('.Left.Earwear.field select').val('');$('.Left.Earwear.field').removeClass('required');$('.Left.Earwear.field').removeClass('mage-error');$('.Left.Earwear.field select').attr('disabled','disabled');}else if(leftReceiver){$('.Left.Earwear.field select').removeAttr('disabled');if(!window.optionalEarwears){$('.Left.Earwear.field').addClass('required');}} if(rightReceiver=='ERU'){$('.Right.Earwear.field select').val('');$('.Right.Earwear.field').removeClass('required');$('.Right.Earwear.field').removeClass('mage-error');$('.Right.Earwear.field select').attr('disabled','disabled');}else if(rightReceiver){$('.Right.Earwear.field select').removeAttr('disabled');if(!window.optionalEarwears){$('.Right.Earwear.field').addClass('required');}}},initObservable:function(){this._super().observe(['checkwarranty']);return this;}});});