- Home
- Mezcal
- Alipus Mezcal
- Alipús San Luis del Río Mezcal
tags do NOT run inside <<< JS $rbIsLoggedIn = Yii::$app->user->isGuest ? 'false' : 'true'; $cartRedirectPages = [ '/cart/info', '/cart/shipping', '/shop/cart/information', '/cart/shippnig', '/cart/payment',]; $currentUrl = Yii::$app->request->getUrl(); $shouldRedirect = in_array($currentUrl, $cartRedirectPages); $js = <<< JS document.getElementById('mySelectedBrand1').addEventListener('change', function () { this.value = this.value; }); var shouldRedirect = "$shouldRedirect"; if(shouldRedirect){ $('#mobileCartIcon').on('click',function(){ // if (window.innerWidth <= 768) { // Mobile screen size window.location.href = "/?open_cart=1"; // } }) } //open cart back to checkout const params = new URLSearchParams(window.location.search); if (params.get('open_cart') === '1') { document.body.classList.add('cart-sidebar-open'); } //end open cart back to checkout var currentCartQty = "$currentCartQty"; var RB_IS_LOGGED_IN = $rbIsLoggedIn; window.RBWishlist = { maxItems: 20, parse: function () { var raw = (typeof Cookies !== 'undefined') ? Cookies.get('wishList') : null; if (!raw || raw === 'null' || raw === '[]') { return []; } try { var parsed = JSON.parse(raw); if (Array.isArray(parsed)) { return parsed.map(function (id) { return parseInt(id, 10); }).filter(function (id) { return id > 0; }); } } catch (e) {} return String(raw).replace(/[\[\]"\s]/g, '').split(',').map(function (id) { return parseInt(id, 10); }).filter(function (id) { return id > 0; }); }, setLocal: function (ids) { ids = Array.isArray(ids) ? ids.map(function (id) { return parseInt(id, 10); }).filter(function (id) { return id > 0; }) : []; if (ids.length > this.maxItems) { ids = ids.slice(0, this.maxItems); } if (ids.length === 0) { Cookies.remove('wishList'); $('.active-wishList').removeClass('active'); $('.whishlist-popup').addClass('d-none'); } else { Cookies.set('wishList', JSON.stringify(ids), { expires: 365, path: '/' }); $('.active-wishList').addClass('active'); $('.whishlist-popup').removeClass('d-none'); } $(document).trigger('wishlist:updated', [ids]); return ids; }, persist: function (ids) { ids = this.setLocal(ids); if (!RB_IS_LOGGED_IN) { return ids; } $.post('/shop/cart/save-account-wishlist', { product_ids: ids }, function (res) { if (res && res.success && Array.isArray(res.products)) { window.RBWishlist.setLocal(res.products); } }, 'json'); return ids; }, toggle: function (productId, wishAction) { productId = parseInt(productId, 10); var ids = this.parse(); var index = ids.indexOf(productId); var action = wishAction || 'toggle'; if (action === 'remove' || (action === 'toggle' && index !== -1)) { if (index !== -1) { ids.splice(index, 1); } action = 'remove'; } else { if (ids.length >= this.maxItems && index === -1) { return { full: true, ids: ids }; } if (index === -1) { ids.push(productId); } action = 'add'; } this.setLocal(ids); if (RB_IS_LOGGED_IN) { $.post('/shop/cart/toggle-account-wishlist', { product_id: productId, wish_action: action }, function (res) { if (res && res.success && Array.isArray(res.products)) { window.RBWishlist.setLocal(res.products); } }, 'json'); } return { full: false, ids: ids, action: action }; }, syncFromServer: function () { if (!RB_IS_LOGGED_IN) { return; } var self = this; $.post('/shop/cart/sync-account-wishlist', { product_ids: self.parse() }, function (res) { if (res && res.success && Array.isArray(res.products)) { self.setLocal(res.products); } }, 'json'); }, refreshHearts: function () { var ids = this.parse(); $('[id="select-wish"], .select-wish').each(function () { var productId = parseInt($(this).data('id'), 10); if (!productId) { return; } var inList = ids.indexOf(productId) !== -1; var blankHeart = $(this).find('.blank-wish, #blank-wish'); var darkHeart = $(this).find('.dark-wish, #dark-wish'); if (inList) { blankHeart.addClass('d-none'); darkHeart.removeClass('d-none'); $(this).attr('data-original-title', 'Remove from wishlist').attr('title', 'Remove from wishlist'); } else { blankHeart.removeClass('d-none'); darkHeart.addClass('d-none'); $(this).attr('data-original-title', 'Add to wishlist').attr('title', 'Add to wishlist'); } }); } }; $(document).on('wishlist:updated', function () { if (window.RBWishlist) { window.RBWishlist.refreshHearts(); } }); var ids = JSON.parse('$ids'); if (window.localStorage && $(window).width() > 991) { const verify = localStorage.getItem('verify'); if (verify === null) { $('body').addClass('no-verify'); $('.no-verify .greet').css({ opacity: 1 }); }else if (verify === 'false') { const firstTime = localStorage.getItem('firsttime'); if (firstTime === 'true') { $('body').removeClass('no-verify'); localStorage.setItem('firsttime', 'false'); } else { $('body').addClass('no-verify'); $('.no-verify .greet').css({ opacity: 1 }); } }else if (verify === 'true') { $('body').removeClass('no-verify'); } } $("#js-product").val(""); if($(window).width() < 992) { $('.header-search').appendTo($('.header-top-custom-mobile')); } $("#subscribe-submit-btn").click(function() { if(!$("#sub-chk").is(":checked")){ alert('You must accept terms and conditions'); $("#sub-chk").focus(); return; } if(!$('#sub-fullname').val()){ alert('Enter Full Name'); $('#sub-fullname').focus(); return; } if(!$('#sub-phone').val()){ alert('Enter Phone Number'); $('#sub-phone').focus(); return; } $("#sub-phone,#sub-fullname").val(''); $("#subscribeModal").modal('hide'); }) $(".header-nav-toggle").click(function(){ $("body").addClass("body-menu"); }); $(".header-nav-close").click(function(){ $("body").removeClass("body-menu"); }); $(document).on('click',function(){ if ($(window).width() > 992 && $('#ui-id-2').hasClass('d-flex')) { $('#ui-id-2').removeClass('d-flex custom-flex'); } }) const stateAbbreviations = {"Alabama": "AL","Alaska": "AK","Arizona": "AZ","Arkansas": "AR","California": "CA","Colorado": "CO","Connecticut": "CT","Delaware": "DE","Florida": "FL","Georgia": "GA","Hawaii": "HI","Idaho": "ID", "Illinois": "IL","Indiana": "IN","Iowa": "IA","Kansas": "KS","Kentucky": "KY","Louisiana": "LA","Maine": "ME","Maryland": "MD","Massachusetts": "MA","Michigan": "MI","Minnesota": "MN","Mississippi": "MS","Missouri": "MO", "Montana": "MT","Nebraska": "NE","Nevada": "NV","New Hampshire": "NH","New Jersey": "NJ","New Mexico": "NM","New York": "NY","North Carolina": "NC","North Dakota": "ND","Ohio": "OH","Oklahoma": "OK","Oregon": "OR", "Pennsylvania": "PA","Rhode Island": "RI","South Carolina": "SC","South Dakota": "SD","Tennessee": "TN","Texas": "TX","Utah": "UT","Vermont": "VT","Virginia": "VA","Washington": "WA","West Virginia": "WV","Wisconsin": "WI","Wyoming": "WY" }; $(document).ready(()=>{ const shipToDropdown = $("#ship-to"); const shipToDropdown_mobile = $(".ship-to-mobile"); const changeLocationBtn = $(".change-location_btn"); const dlDropDown = $(".dlDropDown"); changeLocationBtn.click( function() { $('.dropdown-menu').dropdown('toggle'); dlDropDown.dropdown("toggle"); $('.dlDropDown').parent().hide(); // Set the size attribute of the dropdown to display all options shipToDropdown.attr("size", shipToDropdown.children().length/2); shipToDropdown.focus(); }); // Add a blur event listener to the dropdown to reset its size after selection shipToDropdown.on("blur", function() { shipToDropdown.attr("size", 1); }); shipToDropdown_mobile.on("blur", function() { shipToDropdown_mobile.attr("size", 1); }); if($("#ship-to").val()=='' && !document.cookie.includes("location_set=true")) { // Perform reverse geocoding using Nominatim API fetch('/site/get-api-details') .then(response => response.json()) .then(data => { if(data.country_code!="US"){ $(".address_h3").addClass('nbold') $(".address_h3").text("We detected you are located in "+data.region) $(".address_p").text("Due to regulations we are unable to deliver to your location") $(".confirm-location_btn").hide() }else{ $(".address_h3").removeClass('nbold') $(".address_p").text("Choose location for state-specific products") $(".address_h3").text("We detected you are located in "+data.region) $(".confirm-location_btn").show() } const shortCode = data.region_code || "CA"; $('.dlDropDown').parent().show(); $('.dlDropDown').dropdown('show'); $("#geolocation-state").text(shortCode); // Set the cookie so popup won't show again document.cookie = "location_set=true; path=/; max-age=31536000"; }) .catch(error => { console.error('Error getting state:', error); }); }else{ $("#mobilehlid").hide() } $(".confirm-location_btn").click(function (){ $('.dropdown-menu').dropdown('toggle'); dlDropDown.dropdown("toggle"); $('.dlDropDown').parent().hide(); $("#ship-to").val($("#geolocation-state").text()).change() }) var text = []; if(mobileCheck()){ $("#header_text_mobile span").each(function(i,v){ text.push($(v).html());}) } else { $("#header_text_multiple span").each(function(i,v){text.push($(v).html());}) } if(text.length > 1){ var count = 0; setInterval(function () { count++; $("#header_text").fadeOut(400, function () { $(this).html(text[count % text.length]).fadeIn(400); }); }, 5000); } var flat_text = []; // if(mobileCheck()){ $("#header_text_mobile span").each(function(i,v){ text.push($(v).html());}) } // else { $("#header_flat_text_multiple span").each(function(i,v){flat_text.push($(v).html());}) // } if(flat_text.length > 1){ var count = 0; setInterval(function () { count++; $("#flat_text").fadeOut(400, function () { $(this).html(flat_text[count % flat_text.length]).fadeIn(400); }); }, 5000); } let headerState = $("#ship-to").val(); // $(".mobile-state-select").change(function (){ // dlDropDown.dropdown("toggle"); // $('.dlDropDown').parent().hide(); // $(".ship-to-mobile").val( $(".mobile-state-select").val()) // $(".ship-to-mobile").change().trigger() // }) $(".mobile-state-select").change(function (){ // Check if elements exist before manipulating them var dlDropDown = $(".dlDropDown"); var shipToMobile = $(".ship-to-mobile"); var selectedValue = $(this).val(); if (dlDropDown.length > 0) { dlDropDown.dropdown("toggle"); dlDropDown.parent().hide(); } if (shipToMobile.length > 0 && selectedValue) { shipToMobile.val(selectedValue); shipToMobile.change().trigger('change'); } }); $("#ship-to,.ship-to-mobile").change(function () { $('.ship-desktop-wrp ').addClass("d-none"); dlDropDown.dropdown("toggle"); const newState = this.value; $.ajax({ url: '/site/set-state', data: {state:this.value}, method: 'POST', }) headerState = $("#ship-to").val(); if($(window).width() < 992){ $('.truck-icon').remove() $('.header-panel .header-links-icon').css('display', 'block'); $('.ship-to-mobile').css('display', ''); $('.ship-to-mobile').css('opacity', '1'); // $('.ship-to-mobile').css('margin-left', '-9px'); $('.dropdown-menu').addClass('d-none') } shipToDropdown.attr("size", 1); shipToDropdown_mobile.attr("size", 1); }) }) $('#mySelectedBrand,#mySelectedBrand1').select2({ placeholder: 'Shop by Brand', allowClear: true, matcher: function (params, data) { if ($.trim(params.term) === '') { delete data._matchPriority; return data; } if (typeof data.text === 'undefined') { return null; } var term = params.term.toLowerCase(); var text = data.text.toLowerCase(); // Keep "All" only for empty-search state. if (text === 'all') { return null; } var startsWithMatch = text.indexOf(term) === 0; var containsMatch = text.indexOf(term) > -1; if (startsWithMatch) { data._matchPriority = 0; return data; } if (containsMatch) { data._matchPriority = 1; return data; } return null; }, sorter: function (data) { var hasPriority = data.some(function (item) { return typeof item._matchPriority === 'number'; }); if (!hasPriority) { var allOption = data.filter(function (item) { return (item.text || '').toLowerCase() === 'all'; }); var otherOptions = data.filter(function (item) { return (item.text || '').toLowerCase() !== 'all'; }); return allOption.concat(otherOptions); } return data.sort(function (a, b) { var aPriority = typeof a._matchPriority === 'number' ? a._matchPriority : 2; var bPriority = typeof b._matchPriority === 'number' ? b._matchPriority : 2; if (aPriority !== bPriority) { return aPriority - bPriority; } return a.text.localeCompare(b.text); }); } }); $('#mySelectedBrand,#mySelectedBrand1').on('select2:open', function () { $('.select2-container--open .select2-search__field').attr('placeholder', 'Type a brand'); }); $("#mySelectedBrand,#mySelectedBrand1").on('select2:select', function(e) { e.preventDefault(); var baseUrl = window.location.protocol + "//" + window.location.host; var selectedBrandId = $(this).val(); var newText = selectedBrandId.replaceAll(' ', '-'); var redirectUrl = baseUrl + '/brand/'+newText; window.location.href = redirectUrl; }); $(".cart-sticky-btn button , .cart-sidebar").click(function(){ $("body").addClass("cart-sidebar-open"); }); $(document).on('click','.cart-popup-overlay , .cart-sidebar-popup-head button , .pop-up-shipping',function() { $("body").removeClass("cart-sidebar-open"); }); function updateMinusButtons() { $('.js-cart-item-update').each(function() { var qty = parseInt($(this).val()) || 1; var minusBtn = $(this).closest('.number').find('.minus-pop-up'); if (qty > 1) { minusBtn.removeClass('disabled'); } else { minusBtn.addClass('disabled'); } }); } updateMinusButtons(); $(document).on('pjax:complete', function() { updateMinusButtons(); }); $(document).on('click', '.plus-pop-up' ,function() { console.log("...plus-pop-up"); $('.cart-sidebar-popup').addClass('disabled'); var input = $(this).parent().find('input'); input.next('.input-spinner').removeClass('d-none'); input.addClass('loading'); var currentCartCount = parseInt($('.js-count-cart').first().text().replace(/[^\d]/g,''), 10) || 0; var total = parseFloat($("#js-cart-cost").text().replace('$', '').replace(',', '')) + parseFloat(input.eq(0).data('price')); $("#checkout").attr("href", "/shop/cart/information"); if("$eng_flag" == 1){ if($.inArray(parseInt($(this)[0].previousElementSibling.previousElementSibling.dataset.id), ids) !== -1) alert("This will increase only product quantity not engraving..."); } let max = $(this).parent().find('input').data('max'); console.log("max", max); console.log("input.val()", input.val()); if(currentCartCount < 20){ console.log("currentCartCount iffffff"); if(max != input.val()){ console.log("IFFFFFFFF max != input.val() "); if(currentCartQty == 20){ alert("You can order a maximum of 20 bottles only.") setTimeout(function () { input.removeClass('loading'); }, 4000); } if(currentCartQty != 20){ input.val(parseInt(input.val()) + 1); currentCartQty++; } input.change(); return false; }else{ console.log("ELSEEEEEEEEEEE max != input.val() "); console.log("mainnn---You have exceeded the limited stock"); alert("You have exceeded the limited stock"); $('.cart-sidebar-popup').removeClass('disabled'); input.next('.input-spinner').addClass('d-none'); input.removeClass('loading'); return } }else{ console.log("currentCartCount elseeee"); alert("You can order a maximum of 20 bottles only."); $('.cart-sidebar-popup').removeClass('disabled'); input.next('.input-spinner').addClass('d-none'); input.removeClass('loading'); return } }); $(document).on('click', '.minus-pop-up' ,function() { $('.cart-sidebar-popup').addClass('disabled'); var input = $(this).parent().find('input') input.next('.input-spinner').removeClass('d-none'); input.addClass('loading'); setTimeout(function () { input.removeClass('loading'); }, 4000); var total = parseFloat($("#js-cart-cost").text().replace('$', '').replace(',', '')) - parseFloat(input.eq(0).data('price')); $("#checkout").attr("href", "/shop/cart/information"); var count = parseInt(input.val()) - 1; count = count < 1 ? 1 : count; currentCartQty --; input.val(count); input.change(); return false; }); $(document).on('change','.js-cart-item-update',function() { let valObj = $(this); let val = $(this).val() let id = $(this).data('id') let price = $(this).data('price') let max = $(this).data('max') let item_price = Number(val) * Number(price) if(val <= max){ $(this).parent().next().children().text('$'+item_price.toFixed(2)) } $('.minus-pop-up, .plus-pop-up').addClass('disabled'); $.post({ url:'/shop/cart/cart-update', data:{id:id,val:val}, success:function(res) { $('.js-count-cart').text(res.count); $('.js-cost-cart').text(res.cost) $('.js-cart-cost').text(res.cost) if(res.success == false){ $('.js-count-cart').text(res.count); $('.js-cost-cart').text(res.cost) $('.js-cart-cost').text(res.cost) $(valObj).parent().next().children().text('$'+(valObj.data('max')* Number(price)).toFixed(2)); alert(res.msg); valObj.val(valObj.data('max')) } $.pjax.reload({container: "#cart-pop-up", timeout: false}) .done(function() { if ($('#js-container-cart').length > 0) { $.pjax.reload({container: "#js-container-cart", timeout: false}) .done(function() { $.pjax.reload({container: "#js-cart", timeout: false}) setTimeout(function(){ if(coupon != null && coupon2 !=null){ if(!coupon || coupon2){ $('.js-coupon-name').val(coupon) $('.js-coupon-apply').trigger('click') } } $("#payment-btn").removeClass('disabled'); $("#submit-btn").removeClass('disabled'); }, 500); }) .fail(function() { $.pjax.reload({container: "#js-cart", timeout: false}) }); }else{ $.pjax.reload({container: "#js-cart", timeout: false}) } }) .fail(function() { if ($('#js-container-cart').length > 0) { $.pjax.reload({container: "#js-container-cart", timeout: false}) .done(function() { $.pjax.reload({container: "#js-cart", timeout: false}) }) .fail(function() { $.pjax.reload({container: "#js-cart", timeout: false}) }); }else{ $.pjax.reload({container: "#js-cart", timeout: false}) } }); function finalizeUI() { valObj.next('.input-spinner').addClass('d-none'); valObj.removeClass('loading'); $('.minus-pop-up, .plus-pop-up').removeClass('disabled'); $('.cart-sidebar-popup').removeClass('disabled'); $('.checkout-sidebar').removeClass('disabled'); } } }) }) $(document).on('click','.js-cart-pop-up-item-delete',function() { $('.cart-sidebar-popup').addClass('disabled loading'); // $('.cart-sidebar-popup').addClass('loading'); ids = []; var id; let coupon2 = $('.js-coupon-name').val() if($(this)[0].parentNode.parentElement.nextElementSibling.classList.contains('combo-remove')){ ids.push($(this).data('id')) do{ ids.push($(this)[0].parentNode.parentElement.nextElementSibling.dataset.id) $(this)[0].parentNode.parentElement.nextElementSibling.remove() }while($(this)[0].parentNode.parentElement.nextElementSibling.classList.contains('combo-remove')) }else{ id = $(this).data('id') } $('.pr_pop_up_envaring_'+id).each((index,element) => { $(element).click(); }); $.post({ url:'/shop/cart/cart-item-delete', data:{id:id,ids:ids}, success:function(res) { let coupon = $('.js-coupon-name').val(); var get_tr_element = $('.tr-'+id).next(); if($(get_tr_element).hasClass('tr-engraving')){ $(get_tr_element).find('.js-cart-pop-up-engraving-delete').click(); } $('.js-count-cart').text(res.count); $('.js-cost-cart').text(res.cost) $.pjax.reload({container: "#cart-pop-up", timeout: false}) .done(function() { $('.js-count-cart').text(res.count); $('.js-cost-cart').text(res.cost) if(res.count == 0){ $('.cart-sidebar-popup').removeClass('disabled'); alert("Sorry your cart is empty...") if(!("$company")){ //brand-owner theme code window.location.href = "/"; //brand-owner theme code start }else{ window.location.href = '/site/brand-owner'; } //brand-owner theme code end } setTimeout(function(){ if(coupon != null && coupon2 !=null){ if(!coupon || coupon2){ $('.js-coupon-name').val(coupon) $('.js-coupon-apply').trigger('click') } } $("#payment-btn").removeClass('disabled'); $("#submit-btn").removeClass('disabled'); }, 500); $('.cart-sidebar-popup').removeClass('disabled'); $('.minus-pop-up, .plus-pop-up').removeClass('disabled'); }) .fail(function() { $('.js-count-cart').text(res.count); $('.js-cost-cart').text(res.cost) $('.minus-pop-up, .plus-pop-up').removeClass('disabled'); if(res.count == 0){ alert("Sorry your cart is empty...") if(!("$company")){ //brand-owner theme code window.location.href = "/"; //brand-owner theme code start }else{ window.location.href = '/site/brand-owner'; } //brand-owner theme code end } if(coupon != null && coupon2 !=null){ if(!coupon || coupon2){ $('.js-coupon-name').val(coupon) $('.js-coupon-apply').trigger('click') } } $("#payment-btn").removeClass('disabled'); $("#submit-btn").removeClass('disabled'); }) .done(function() { $('.js-count-cart').text(res.count); $('.js-cost-cart').text(res.cost) if ($('#js-container-cart').length > 0) { $.pjax.reload({container: "#js-container-cart", timeout: false}) .done(function() { $('.js-count-cart').text(res.count); $('.js-cost-cart').text(res.cost) $.pjax.reload({container: "#js-cart", timeout: false}) if(coupon != null && coupon2 !=null){ if(!coupon || coupon2){ $('.js-coupon-name').val(coupon) $('.js-coupon-apply').trigger('click') } } $("#payment-btn").removeClass('disabled'); $("#submit-btn").removeClass('disabled'); }) .fail(function() { $.pjax.reload({container: "#js-cart", timeout: false}) // if(coupon) { $('.js-coupon-apply').trigger('click') } if(coupon != null && coupon2 !=null){ if(!coupon || coupon2){ $('.js-coupon-name').val(coupon) $('.js-coupon-apply').trigger('click') } } $("#payment-btn").removeClass('disabled'); $("#submit-btn").removeClass('disabled'); }); }else{ $.pjax.reload({container: "#js-cart", timeout: false}) // if(coupon) { $('.js-coupon-apply').trigger('click') } if(coupon != null && coupon2 !=null){ if(!coupon || coupon2){ $('.js-coupon-name').val(coupon) $('.js-coupon-apply').trigger('click') } } $("#payment-btn").removeClass('disabled'); $("#submit-btn").removeClass('disabled'); } $('.minus-pop-up, .plus-pop-up').removeClass('disabled'); }) .fail(function() { $('.js-count-cart').text(res.count); $('.js-cost-cart').text(res.cost) if ($('#js-container-cart').length > 0) { $.pjax.reload({container: "#js-container-cart", timeout: false}) .done(function() { $.pjax.reload({container: "#js-cart", timeout: false}) // if(coupon) { $('.js-coupon-apply').trigger('click') } if(coupon != null && coupon2 !=null){ if(!coupon || coupon2){ $('.js-coupon-name').val(coupon) $('.js-coupon-apply').trigger('click') } } $("#payment-btn").removeClass('disabled'); $("#submit-btn").removeClass('disabled'); }) .fail(function() { $.pjax.reload({container: "#js-cart", timeout: false}) // if(coupon) { $('.js-coupon-apply').trigger('click') } if(coupon != null && coupon2 !=null){ if(!coupon || coupon2){ $('.js-coupon-name').val(coupon) $('.js-coupon-apply').trigger('click') } } $("#payment-btn").removeClass('disabled'); $("#submit-btn").removeClass('disabled'); }); }else{ $.pjax.reload({container: "#js-cart", timeout: false}) // if(coupon) { $('.js-coupon-apply').trigger('click') } if(coupon != null && coupon2 !=null){ if(!coupon || coupon2){ $('.js-coupon-name').val(coupon) $('.js-coupon-apply').trigger('click') } } $("#payment-btn").removeClass('disabled'); $("#submit-btn").removeClass('disabled'); } $('.minus-pop-up, .plus-pop-up').removeClass('disabled'); }); } }) }) function shippingButtons(){ // if(parseFloat($("#cart_pop_up_total").text().replace('$', '').replace(',', '')) < 35.99){ //club code // $("#shipping").prop('disabled',true); // $("#submit-btn").prop('disabled',true); // $("#payment-btn").prop('disabled',true); // $("#shiping-btn").append('
'); // $("#shiping-btn-1").append('
');
// }else if(parseFloat($("#cart_pop_up_total").text().replace('$', '').replace(',', '')) >= 35.99) {
$("#shipping").prop('disabled',false);
$("#submit-btn").prop('disabled',false);
$("#payment-btn").prop('disabled',false);
$('.disable-shipping').remove();
// }
// $(document).on('click', '#disable-shipping,#disable-shipping-1', function() {
// if(parseFloat($(".js-cost-cart").text().replace('$', '').replace(',', '')) < 35.99 && "$is_club" != 1){ //club code){
// alert("You have not reached the $35.99 minimum cart value.");
// }
// });
}
$(document).on('click','.js-cart-pop-up-engraving-delete',function() {
let id = $(this).data('id')
$.post({
url:'/shop/cart/delete-engraving',
data:{id:id},
success:function(res) {
$('.js-count-cart').text(res.count);
$('.js-cost-cart').text(res.cost)
$.pjax.reload({container: "#cart-pop-up", timeout: false})
.done(function() {
if ($('#js-container-cart').length > 0) {
$.pjax.reload({container: "#js-container-cart", timeout: false})
.done(function() {
$.pjax.reload({container: "#js-cart", timeout: false})
})
.fail(function() {
$.pjax.reload({container: "#js-cart", timeout: false})
});
}else{
$.pjax.reload({container: "#js-cart", timeout: false})
}
})
.fail(function() {
if ($('#js-container-cart').length > 0) {
$.pjax.reload({container: "#js-container-cart", timeout: false})
.done(function() {
$.pjax.reload({container: "#js-cart", timeout: false})
})
.fail(function() {
$.pjax.reload({container: "#js-cart", timeout: false})
});
}else{
$.pjax.reload({container: "#js-cart", timeout: false})
}
});
}
})
})
$(document).on('click','#cart-pop-up-checkout',function() {
if($("#pop-up-cart-count").text() == 0){
alert("Sorry your cart is empty...");
return false;
}
setTimeout(function(){
if($("#cart_pop_up_total").text().replace('$', '').replace(',', '') < 35.99 && $("#pop-up-cart-count").text() != 0 && "$is_club" != 1){ //club code
alert("You have not reached the $35.99 minimum cart value.");
}
if($("#cart_pop_up_total").text().replace('$', '').replace(',', '') >= 35.99 && $("#pop-up-cart-count").text() != 0){
window.location.href = "/shop/cart/information";
}
},700)
let flag = "$flag";
if(flag == 1){ alert("Bundle discount will be added at checkout..") }
})
$(document).on('click','.edit-gift',function() {
window.location.href = $(this).attr('href');
})
// chat bot js
const chat = document.getElementById("chatbot-chat");
$(".chatbot-open-container2").click(function(){
$("#chatbot-open-container").trigger("click");
});
$("#chatbot-open-container").click(function(){
$("#open-chat-button").toggle(200);
$("#close-chat-button").toggle(200);
$("#chatbot-container").fadeToggle(200);
$.ajax({ url: '/bot/clear', })
});
document.getElementById("chatbot-new-message-send-button").addEventListener("click", newInput);
document.getElementById("chatbot-input").addEventListener('keypress', function (e) {
if (e.key === 'Enter') {
newInput();
}
});
$(".pre-question").on("click", function() {
$(".chat-bot-box").removeClass('d-none')
$(".option-chat-box").addClass('d-none')
newText = $(this).text();
if (newText != ""){
document.getElementById("chatbot-input").value = "";
addMessage("sent", newText);
generateResponse(newText);
$("#chatbot-input").removeAttr("disabled");
}
});
$(".back-question").on("click", function() {
$(".chat-bot-box").addClass('d-none')
$(".option-chat-box").removeClass('d-none')
})
$(".back-chat").on("click", function() {
$(".chat-bot-box").removeClass('d-none')
$(".option-chat-box").addClass('d-none')
})
function newInput(){
newText = document.getElementById("chatbot-input").value;
if(document.getElementById("chatbot-zip-input")){
newEmail = document.getElementById("chatbot-zip-input").value;
}
if(typeof(newEmail) !== "undefined"){
if (newText != "" && newEmail != ""){
$("#chatbot-input").css('border','')
$("#chatbot-zip-input").css('border','')
document.getElementById("chatbot-input").value = "";
if(document.getElementById("chatbot-zip-input")){
generateResponse(newText,newEmail);
addMessage("sent", 'Order Id:- '+newText +'
Zip Code:- '+newEmail);
}else{
generateResponse(newText);
addMessage("sent", newText);
}
}else{
if(newText == "" && newEmail == ""){
$("#chatbot-input").css('border','2px solid red')
$("#chatbot-zip-input").css('border','2px solid red')
}else if(newText == ""){
$("#chatbot-input").css('border','2px solid red')
if(newEmail != ""){ $("#chatbot-zip-input").css('border','') }
}else if(newEmail == ""){
if(newText != ""){ $("#chatbot-input").css('border','') }
$("#chatbot-zip-input").css('border','2px solid red')
}else{
$("#chatbot-input").css('border','')
$("#chatbot-zip-input").css('border','')
}
}
}else{
generateResponse(newText);
addMessage("sent", newText);
document.getElementById("chatbot-input").value = "";
}
}
function addMessage(type, text){
let messageDiv = document.createElement("div");
let responseText = document.createElement("p");
// responseText.appendChild(document.createTextNode(text));
responseText.innerHTML = text;
if (type == "sent"){
messageDiv.classList.add("chatbot-messages", "chatbot-sent-messages");
} else if (type == "received"){
messageDiv.classList.add("chatbot-messages", "chatbot-received-messages");
}
messageDiv.appendChild(responseText);
chat.prepend(messageDiv);
}
function generateResponse(prompt,zipPrompt = null){
$.ajax({
url: '/bot/chat',
data: {message:prompt, zip:zipPrompt},
method: 'POST',
success:function(res) {
$('#chatbot-chat').animate({ scrollTop: 0 }, '300');
if(prompt.trim() === "What is my order status?"){
$('#chatbot-input').attr('type', 'number');
$('#chatbot-input').attr('placeholder', 'Enter the order number...');
$('#chatbot-input-container').append('')
}else{
if(document.getElementById("chatbot-zip-input")){
document.getElementById("chatbot-zip-input").value = "";
if(!res.orderfield || res.orderfield != "order_status"){
// $('#chatbot-container').css('height', '');
$('#chatbot-input').attr('type', 'text');
$('#chatbot-input').attr('placeholder', 'Type a command here...');
$('#chatbot-zip-input').remove()
}
}
}
addMessage("received", res.message);
}
})
}
$(document).click(function(event) {
var chatContainer = $('#chatbot-container');
var openButton = $('#chatbot-open-container');
var openButton2 = $('.chatbot-open-container2');
if (!chatContainer.is(event.target) && chatContainer.has(event.target).length === 0 &&
!openButton.is(event.target) && openButton.has(event.target).length === 0 && !openButton2.is(event.target) && openButton2.has(event.target).length === 0 && chatContainer.is(':visible')) {
$("#open-chat-button").toggle(200);
$("#close-chat-button").toggle(200);
$("#chatbot-container").fadeToggle(200);
}
});
$(document).ready(function() {
$('#mySelectedBrand').on('select2:open select2:select select2:close', function() {
$('#select2-mySelectedBrand-container').attr('aria-label', 'Shop by Brand');
});
$('#select2-mySelectedBrand-container').attr('aria-label', 'Shop by Brand');
if (window.RBWishlist) {
if (RB_IS_LOGGED_IN) {
window.RBWishlist.syncFromServer();
} else {
let wishlist = Cookies.get('wishList');
if (wishlist && wishlist.trim() !== '' && wishlist !== 'null' && wishlist !== '[]') {
$('.active-wishList').addClass('active');
$('.whishlist-popup').removeClass('d-none');
}
}
}
});
JS;
$this->registerJs($js);
?>