'use strict';(function($){var woofc_timeout=null;$(function(){if(woofc_vars.reload=='yes'){woofc_cart_reload();}});$(document).on('click touch','#woofc-area .woosq-link, #woofc-area .woosq-btn',function(e){woofc_hide_cart();e.preventDefault();});$(document.body).on('added_to_cart',function(){if($('.woofc-checkout-form').length&&!$('.woofc-checkout-form .woocommerce-checkout').length){var data={action:'woofc_get_checkout_form',};$.post(woofc_vars.ajax_url,data,function(response){$('.woofc-checkout-form').html(response);if(woofc_vars.wc_checkout_js!==''){$.getScript(woofc_vars.wc_checkout_js);}});} if(jQuery('.woofc-checkout-area').length&&(woofc_vars.instant_checkout==='yes')){jQuery(document.body).trigger('update_checkout');} if(woofc_vars.auto_show==='yes'){setTimeout(function(){woofc_show_cart();},100);}});$(document.body).on('wc_fragments_loaded',function(){woofc_cart_loaded();});$(document.body).on('wc_fragments_refreshed',function(){woofc_cart_loaded();});$(document.body).on('woofc_cart_reload',function(){if((woofc_vars.is_cart=='1')&&$('form.woocommerce-cart-form').length){$(document.body).trigger('wc_update_cart');} if((woofc_vars.is_checkout=='1')&&$('form.woocommerce-checkout').length){$(document.body).trigger('update_checkout');}});if(woofc_vars.manual_show!=''){$(document).on('click touch',woofc_vars.manual_show,function(e){woofc_toggle_cart();e.preventDefault();});} $(document).on('click touch','.woofc-item-qty-plus, .woofc-item-qty-minus',function(){var $qty=$(this).closest('.woofc-item-qty').find('.qty'),val=parseFloat($qty.val()),max=parseFloat($qty.attr('max')),min=parseFloat($qty.attr('min')),step=$qty.attr('step');if(!val||val===''||val==='NaN'){val=0;} if(max===''||max==='NaN'){max='';} if(min===''||min==='NaN'){min=0;} if(step==='any'||step===''||step===undefined||parseFloat(step)==='NaN'){step=1;}else{step=parseFloat(step);} if($(this).is('.woofc-item-qty-plus')){if(max&&(max===val||val>max)){$qty.val(max);}else{$qty.val((val+step).toFixed(woofc_decimal_places(step)));}}else{if(val-step<=0){if((woofc_vars.confirm_remove==='yes')){if(confirm(woofc_vars.confirm_remove_text)){woofc_remove_item($qty.closest('.woofc-item'));}}else{woofc_remove_item($qty.closest('.woofc-item'));} return false;} if(min&&(min===val||val0){$qty.val((val-step).toFixed(woofc_decimal_places(step)));}} $qty.trigger('change');});$(document).on('change','.woofc-area .qty',function(){var item_key=$(this).closest('.woofc-item').attr('data-key');var item_qty=$(this).val();woofc_update_qty(item_key,item_qty);});$(document).on('keyup','.woofc-area .qty',function(){var $this=$(this);if($this.closest('.woopq-quantity-input').length){return;} if(woofc_timeout!=null)clearTimeout(woofc_timeout);woofc_timeout=setTimeout(woofc_check_qty,1000,$this);});$(document).on('click touch','.woofc-area .woofc-item-remove',function(){if(woofc_vars.confirm_remove==='yes'){if(confirm(woofc_vars.confirm_remove_text)){woofc_remove_item($(this).closest('.woofc-item'));}}else{woofc_remove_item($(this).closest('.woofc-item'));}});$(document).on('click touch','.woofc-overlay',function(){woofc_hide_cart();});$(document).on('click touch','.woofc-close',function(){woofc_hide_cart();});$(document).on('click touch','.woofc-continue-url',function(){var url=$(this).attr('data-url');woofc_hide_cart();if(url!==''){window.location.href=url;}});$(document).on('click touch','.woofc-empty-cart',function(){woofc_cart_loading();var data={action:'woofc_empty_cart',security:woofc_vars.nonce,};$.post(woofc_vars.ajax_url,data,function(response){woofc_cart_reload();});});$(document).on('click touch','.woofc-count',function(e){woofc_toggle_cart();e.preventDefault();});$(document).on('click touch','.woofc-menu-item a',function(e){if(woofc_vars.cart_url!=''){window.location.href=woofc_vars.cart_url;}else{woofc_toggle_cart();} e.preventDefault();});$(document).on('click touch','.woofc-cart, .woofc-btn',function(e){woofc_toggle_cart();e.preventDefault();});$(document).on('click touch','.woofc-cart-link a',function(e){if(woofc_vars.cart_url!=''){window.location.href=woofc_vars.cart_url;}else{woofc_toggle_cart();} e.preventDefault();});$(document).on('click touch','.woofc-back',function(e){e.preventDefault();$('.woofc-checkout-area').addClass('woofc-hide');$('body').removeClass('woofc-show-checkout');$('.woofc-cart-area').removeClass('woofc-hide');woofc_slick();});$(document).on('click touch','.woofc-action-checkout',function(e){if((woofc_vars.instant_checkout==='yes')&&$('.woofc-checkout-area').length){e.preventDefault();$('.woofc-cart-area').addClass('woofc-hide');$('body').addClass('woofc-show-checkout');$('.woofc-checkout-area').removeClass('woofc-hide');}});$(document).on('click touch','.woofc-area #place_order',function(e){setTimeout(function(){$('.woofc-area-mid').scrollTop($('.woofc-area-mid').scrollTop()+ $('.woofc-checkout-form').position().top);},1000);});$(document).on('updated_checkout',function(e){if($('body').hasClass('woofc-show-checkout')){$('.woofc-cart-area').addClass('woofc-hide');$('.woofc-checkout-area').removeClass('woofc-hide');} woofc_slick();woofc_perfect_scrollbar();});$(document).on('click touch','.woofc-coupon-check',function(){var coupon_code=$('.woofc-coupon-code').val();if(coupon_code==''){$('.woofc-coupon-code').focus();}else{woofc_cart_loading();var data={action:'woofc_apply_coupon',coupon_code:coupon_code,security:woofc_vars.nonce,};$.post(woofc_vars.ajax_url,data,function(response){woofc_cart_reload();});}});$(document).on('keypress','.woofc-coupon-code',function(e){if(e.keyCode==13){var coupon_code=$('.woofc-coupon-code').val();if(coupon_code!==''){woofc_cart_loading();var data={action:'woofc_apply_coupon',coupon_code:coupon_code,security:woofc_vars.nonce,};$.post(woofc_vars.ajax_url,data,function(response){woofc_cart_reload();});}}});$(document).on('click touch','.woofc-coupon-remove',function(){woofc_cart_loading();var coupon_code=$(this).closest('.woofc-coupon-added').attr('data-code');var data={action:'woofc_remove_coupon',coupon_code:coupon_code,security:woofc_vars.nonce,};$.post(woofc_vars.ajax_url,data,function(response){woofc_cart_reload();});});$(document).on('click touch','.woofc-undo a',function(e){e.preventDefault();woofc_cart_loading();var undo_key=$('body').attr('woofc-undo-key');var data={action:'woofc_undo_remove',item_key:undo_key,security:woofc_vars.nonce,};$.post(woofc_vars.ajax_url,data,function(response){woofc_cart_reload();});$('body').attr('woofc-undo-key','');$('body').attr('woofc-undo-name','');});$(document).on('click touch','.woofc-shipping',function(e){$(this).toggleClass('woofc-shipping-open');$('.woofc-shipping-area').toggleClass('woofc-shipping-area-open');});$(document).on('change','input.woofc-shipping-method',function(e){e.preventDefault();e.stopImmediatePropagation();woofc_cart_loading();var shipping_methods={};$('select.shipping_method, :input[name^=woofc_shipping_method][type=radio]:checked, :input[name^=shipping_method][type=hidden]').each(function(){shipping_methods[$(this).data('index')]=$(this).val();});var data={action:'woofc_update_shipping_method',shipping_methods:shipping_methods,};$.post(woofc_vars.ajax_url,data,function(response){woofc_cart_reload();});});$(document).on('submit','.woofc-area form.woocommerce-shipping-calculator',function(e){e.preventDefault();e.stopImmediatePropagation();woofc_cart_loading();var $form=$(this);$('').attr('type','hidden').attr('name','calc_shipping').attr('value','1').appendTo($form);var formData=$form.serializeArray();var data={action:'woofc_calculate_shipping',};$(formData).each(function(index,obj){data[obj.name]=obj.value;});$.post(woofc_vars.ajax_url,data,function(response){woofc_cart_reload();});});})(jQuery);function woofc_decimal_places(num){var match=(''+num).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);if(!match){return 0;} return Math.max(0,(match[1]?match[1].length:0) -(match[2]?+match[2]:0));} function woofc_update_qty(cart_item_key,cart_item_qty){woofc_cart_loading();var data={action:'woofc_update_qty',cart_item_key:cart_item_key,cart_item_qty:cart_item_qty,security:woofc_vars.nonce,};jQuery.post(woofc_vars.ajax_url,data,function(response){woofc_cart_reload();jQuery(document.body).trigger('woofc_update_qty',[cart_item_key,cart_item_qty]);});} function woofc_remove_item($item){var cart_item_key=$item.attr('data-key');var cart_item_name=$item.attr('data-name');woofc_cart_loading();var data={action:'woofc_remove_item',cart_item_key:cart_item_key,security:woofc_vars.nonce,};jQuery.post(woofc_vars.ajax_url,data,function(response){if(!response||!response.fragments){return;} jQuery(document.body).trigger('removed_from_cart',[response.fragments,response.cart_hash]);jQuery('body').attr('woofc-undo-key',cart_item_key);jQuery('body').attr('woofc-undo-name',cart_item_name);woofc_cart_reload();jQuery(document.body).trigger('woofc_remove_item',[cart_item_key,cart_item_name,response]);});} function woofc_cart_loading(){jQuery('.woofc-inner').addClass('woofc-inner-loading');jQuery('.woofc-count').addClass('woofc-count-loading').removeClass('woofc-count-shake');jQuery(document.body).trigger('woofc_cart_loading');} function woofc_cart_reload(){jQuery(document.body).trigger('wc_fragment_refresh');jQuery(document.body).trigger('woofc_cart_reload');if(jQuery('.woofc-checkout-area').length&&(woofc_vars.instant_checkout==='yes')){jQuery(document.body).trigger('update_checkout');}} function woofc_cart_loaded(){jQuery('.woofc-inner').removeClass('woofc-inner-loading');jQuery('.woofc-count').removeClass('woofc-count-loading').addClass('woofc-count-shake');if((woofc_vars.undo_remove=='yes')&&(jQuery('body').attr('woofc-undo-key')!=undefined)&&(jQuery('body').attr('woofc-undo-key')!='')){var undo_name='Item';if((jQuery('body').attr('woofc-undo-name')!=undefined)&&(jQuery('body').attr('woofc-undo-name')!='')){undo_name='"'+jQuery('body').attr('woofc-undo-name')+'"';} jQuery('.woofc-cart-area .woofc-area-mid').find('.woofc-undo').remove();jQuery('.woofc-cart-area .woofc-area-mid').prepend('
'+ woofc_vars.removed_text.replace('%s',undo_name)+' '+ woofc_vars.undo_remove_text+'
');} woofc_slick();woofc_perfect_scrollbar();jQuery(document.body).trigger('woofc_cart_loaded');} function woofc_perfect_scrollbar(){if(woofc_vars.scrollbar==='yes'){jQuery('.woofc-area .woofc-area-mid').perfectScrollbar({suppressScrollX:true,theme:'wpc'});}} function woofc_slick(){if((woofc_vars.slick==='yes')&&(jQuery('.woofc-cross-sells-product').length>1)){if(jQuery('.woofc-cross-sells-products').hasClass('slick-initialized')){jQuery('.woofc-cross-sells-products').slick('unslick');} jQuery('.woofc-cross-sells-products').slick(JSON.parse(woofc_vars.slick_params));}} function woofc_show_cart(){jQuery('body').addClass('woofc-show');jQuery(document.body).trigger('woofc_show_cart');} function woofc_hide_cart(){jQuery('body').removeClass('woofc-show woofc-show-checkout');jQuery(document.body).trigger('woofc_hide_cart');} function woofc_toggle_cart(){if(jQuery('body').hasClass('woofc-show')){woofc_hide_cart();}else{woofc_show_cart();} jQuery(document.body).trigger('woofc_toggle_cart');} function woofc_check_qty($qty){var is_remove=false;var val=parseFloat($qty.val());var min=parseFloat($qty.attr('min'));var max=parseFloat($qty.attr('max'));var step=parseFloat($qty.attr('step'));var fix=Math.pow(10,Number(woofc_decimal_places(step))+1);if((val==='')||isNaN(val)){val=0;} if((min==='')||isNaN(min)){min=0;} if((step==='')||isNaN(step)){step=1;} var remainder=woofc_float_remainder(val,step);if(remainder>=0){val=Math.round((val-remainder)*fix)/fix;} if(valmax)){val=max;} $qty.val(val);if(is_remove){if((woofc_vars.confirm_remove==='yes')){if(confirm(woofc_vars.confirm_remove_text)){woofc_remove_item($qty.closest('.woofc-item'));}}else{woofc_remove_item($qty.closest('.woofc-item'));}}} function woofc_decimal_places(num){var match=(''+num).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);if(!match){return 0;} return Math.max(0,(match[1]?match[1].length:0) -(match[2]?+match[2]:0));} function woofc_float_remainder(val,step){var valDecCount=(val.toString().split('.')[1]||'').length;var stepDecCount=(step.toString().split('.')[1]||'').length;var decCount=valDecCount>stepDecCount?valDecCount:stepDecCount;var valInt=parseInt(val.toFixed(decCount).replace('.',''));var stepInt=parseInt(step.toFixed(decCount).replace('.',''));return(valInt%stepInt)/Math.pow(10,decCount);}