';
if( value ){
noticeHtml += value.map((x) => `
${x.notice}
`).join('');
}
noticeHtml += '
';
//$('.mfn-chft-apply-coupon').append();
}
$('.mfn-chft-apply-coupon-wrapper').prepend(noticeHtml);
woocart.coupons.removeNotices();
}
button.removeClass('loading');
}
});
},
apply: function() {
$(document).on('click', '.mfn-sidecart-apply-coupon-wrapper .mfn-sidecart-apply-coupon', function(e) {
e.preventDefault();
woocart.coupons.ajax();
});
$(document).on('keypress', '.mfn-sidecart-apply-coupon-wrapper .mfn-sidecart-apply-coupon-input', function(e) {
if (e.which == 13) woocart.coupons.ajax();
});
},
removeNotices: function() {
setTimeout(function() {
$('.mfn-chft-apply-coupon-wrapper .mfn-sidecart-notice').remove();
}, 3000);
}
},
start: function() {
/*if( $('a#header_cart .header-cart-count').length ){
if( $('#Top_bar a#header_cart .header-cart-count').text() == '0' ){
$('.mfn-ch-footer-buttons').hide();
}
}*/
return false;
},
click: function() {
if($('body').hasClass('shop-sidecart-active') && $('.mfn-cart-holder').length ){
$('html').toggleClass('mfn-cart-opened');
woocart.force_open = false;
}
},
refresh: function(){
$.ajax({
url: mfnwoovars.ajaxurl,
data: {
'mfn-woo-nonce': mfnwoovars.wpnonce,
action: 'mfnrefreshcart'
},
type: 'POST',
cache: false,
success: function(response){
$('.mfn-cart-holder .mfn-ch-content').html(response.content);
$('.mfn-cart-holder .mfn-ch-footer .mfn-ch-footer-totals').html(response.footer);
$('.mfn-cart-holder').removeClass('loading');
if( $('body').hasClass('woocommerce-cart') && $('.mfn-builder-content.mfn-cart-tmpl-builder').length ){
$('.mfn-builder-content.mfn-cart-tmpl-builder').removeClass('mfn-cart-tmpl-not-empty mfn-cart-tmpl-empty');
if( !response.total ){
$('.mfn-builder-content.mfn-cart-tmpl-builder').addClass('mfn-cart-tmpl-empty');
}else{
$('.mfn-builder-content.mfn-cart-tmpl-builder').addClass('mfn-cart-tmpl-not-empty');
}
}
// side cart buttons
if( response.total == 0 ){
$('.mfn-ch-footer-buttons').hide();
}else{
$('.mfn-ch-footer-buttons').show();
}
if( woocart.force_open ) woocart.click();
return;
}
});
},
delete: function(id){
$.ajax({
url: mfnwoovars.ajaxurl,
data: {
'mfn-woo-nonce': mfnwoovars.wpnonce,
action: 'mfnremovewooproduct',
pid: id
},
type: 'POST',
cache: false,
success: function(response){
$(document.body).trigger('wc_fragment_refresh');
woocart.refresh();
if($('body').hasClass('woocommerce-cart')){
$('.woocommerce .shop_table .product-remove a.remove[data-product_id="'+id+'"]').trigger('click');
}
}
});
},
updatequantity: function(id, qty) {
$.ajax({
url: mfnwoovars.ajaxurl,
data: {
'mfn-woo-nonce': mfnwoovars.wpnonce,
action: 'mfnchangeqtyproduct',
pid: id,
qty: qty
},
type: 'POST',
cache: false,
success: function(response){
$(document.body).trigger('wc_fragment_refresh');
woocart.refresh();
if($('body').hasClass('woocommerce-cart')){
$('.woocommerce .shop_table .product-remove a.remove[data-product_id="'+id+'"]').parent().siblings('.product-quantity').find('input.qty').val(qty).trigger('change');
$('.woocommerce-cart-form .button[name="update_cart"]').trigger('click');
}
}
});
}
};
woocart.coupons.init();
var mfnFakeSale = {
active: true,
time: function() {
let arr = [20000, 25000, 30000, 35000, 40000, 50000];
return arr[Math.floor(Math.random()*arr.length)];
},
init: function() {
if( $('body').hasClass('mfn-ui') ) return;
if( mfnFakeSale.checkCookie("mfnFakeSale") ) mfnFakeSale.active = false;
if( typeof mfn_fake_sale === 'undefined' || !mfnFakeSale.active ) return;
let delay = typeof mfn_fake_sale.delay !== 'undefined' ? mfn_fake_sale.delay : 5;
delay = parseFloat(delay)*1000;
setTimeout(mfnFakeSale.show, delay);
$(document).on('click', '.mfn-fake-sale-noti .mfn-fake-sale-noti-close', function(e) {
e.preventDefault();
mfnFakeSale.active = false;
mfnFakeSale.hide();
mfnFakeSale.addCookie(1, "mfnFakeSale");
});
},
show: function() {
var item = mfn_fake_sale.items[Math.floor(Math.random() * mfn_fake_sale.items.length)];
var html = `