' : '' ) + (aSlide.title ? '
' + aSlide.title + '
' : '' ) + (aSlide.button && aSlide.link ? '
' + aSlide.button + '
' : '' ) + '' + (aSlide.link ? '' : '' ) + '' ); }); if(!slides.length){ $(".js-home-main-slider-container").addClass("hidden"); $(".js-home-empty-slider-container").removeClass("hidden"); $(".js-home-mobile-slider-visibility").removeClass("d-md-none"); }else{ $(".js-home-main-slider-container").removeClass("hidden"); $(".js-home-empty-slider-container").addClass("hidden"); $(".js-home-mobile-slider-visibility").addClass("d-md-none"); } }, changeAutoRotation: function(){ }, }; var preloadImagesValue = false; var lazyValue = true; var loopValue = true; var paginationClickableValue = true; var homeSwiper = new Swiper ('.js-home-slider', { preloadImages: preloadImagesValue, lazy: lazyValue, autoplay: slider_autoplay, pagination: { el: '.js-swiper-home-pagination', clickable: paginationClickableValue, }, navigation: { nextEl: '.js-swiper-home-next', prevEl: '.js-swiper-home-prev', }, }); var homeMobileSwiper = new Swiper ('.js-home-slider-mobile', { preloadImages: preloadImagesValue, lazy: lazyValue, autoplay: slider_autoplay, pagination: { el: '.js-swiper-home-pagination-mobile', clickable: paginationClickableValue, }, navigation: { nextEl: '.js-swiper-home-next-mobile', prevEl: '.js-swiper-home-prev-mobile', }, }); var lazyVal = true; var watchOverflowVal = true; var centerInsufficientSlidesVal = true; var slidesPerViewDesktopVal = 4; var slidesPerViewMobileVal = 1.5; var featuredSwiper = new Swiper ('.js-swiper-featured', { lazy: lazyVal, watchOverflow: watchOverflowVal, centerInsufficientSlides: centerInsufficientSlidesVal, threshold: 5, watchSlideProgress: true, watchSlidesVisibility: true, slideVisibleClass: 'js-swiper-slide-visible', loop: true, navigation: { nextEl: '.js-swiper-featured-next', prevEl: '.js-swiper-featured-prev', }, slidesPerView: slidesPerViewMobileVal, breakpoints: { 768: { slidesPerView: slidesPerViewDesktopVal, } } }); var newSwiper = new Swiper ('.js-swiper-new', { lazy: lazyVal, watchOverflow: watchOverflowVal, centerInsufficientSlides: centerInsufficientSlidesVal, threshold: 5, watchSlideProgress: true, watchSlidesVisibility: true, slideVisibleClass: 'js-swiper-slide-visible', loop: true, navigation: { nextEl: '.js-swiper-new-next', prevEl: '.js-swiper-new-prev', }, slidesPerView: slidesPerViewMobileVal, breakpoints: { 768: { slidesPerView: slidesPerViewDesktopVal, } } }); var saleSwiper = new Swiper ('.js-swiper-sale', { lazy: lazyVal, watchOverflow: watchOverflowVal, centerInsufficientSlides: centerInsufficientSlidesVal, threshold: 5, watchSlideProgress: true, watchSlidesVisibility: true, slideVisibleClass: 'js-swiper-slide-visible', navigation: { nextEl: '.js-swiper-sale-next', prevEl: '.js-swiper-sale-prev', }, slidesPerView: slidesPerViewMobileVal, breakpoints: { 768: { slidesPerView: slidesPerViewDesktopVal, } } }); var demoFeaturedSwiper = new Swiper ('.js-swiper-featured-demo', { lazy: true, loop: true, watchOverflow: true, centerInsufficientSlides: true, slidesPerView: 1.5, navigation: { nextEl: '.js-swiper-featured-demo-next', prevEl: '.js-swiper-featured-demo-prev', }, breakpoints: { 640: { slidesPerView: 4, } } }); var width = window.innerWidth; if (width parseInt(max_installments_without_interests[0])) { if (installment_data.without_interests) { return [number_of_installment, installment_data.installment_value.toFixed(2)]; } } return max_installments_without_interests; } function get_max_installments_with_interests(number_of_installment, installment_data, max_installments_with_interests) { if (parseInt(number_of_installment) > parseInt(max_installments_with_interests[0])) { if (installment_data.without_interests == false) { return [number_of_installment, installment_data.installment_value.toFixed(2)]; } } return max_installments_with_interests; } function refreshInstallmentv2(price){ $(".js-modal-installment-price" ).each(function( index ) { const installment = Number($(this).data('installment')); $(this).text(LS.currency.display_short + (price/installment).toLocaleString('de-DE', {maximumFractionDigits: 2, minimumFractionDigits: 2})); }); } function refreshPaymentDiscount(price){ $(".js-price-with-discount" ).each(function( index ) { const payment_discount = $(this).data('payment-discount'); $(this).text(LS.formatToCurrency(price - ((price * payment_discount) / 100))) }); } function changeVariant(variant) { $(".js-product-detail .js-shipping-calculator-response").hide(); $("#shipping-variant-id").val(variant.id); var parent = $("body"); if (variant.element) { parent = $(variant.element); } var sku = parent.find('#sku'); if(sku.length) { sku.text(variant.sku).show(); } var installment_helper = function($element, amount, price){ $element.find('.js-installment-amount').text(amount); $element.find('.js-installment-price').attr("data-value", price); $element.find('.js-installment-price').text(LS.currency.display_short + parseFloat(price).toLocaleString('de-DE', { minimumFractionDigits: 2 })); if(variant.price_short && Math.abs(variant.price_number - price * amount) 1 ? max_installments_without_interests : max_installments_with_interests; if(installments_to_use[0] 1) { $quantity_input.val( parseInt($quantity_input.val(), 10) - 1); } }); var head_height = $(".js-head-main").outerHeight(); if ($(window).width() > 768) { $("#cart-sticky-summary").css("top" , head_height + 10); } $(document).on("click", ".js-addtocart:not(.js-addtocart-placeholder)", function (e) { var $productContainer = $(this).closest('.js-product-container'); var $productVariants = $productContainer.find(".js-variation-option"); var $productButton = $productContainer.find("input[type='submit'].js-addtocart"); var $productButtonPlaceholder = $productContainer.find(".js-addtocart-placeholder"); var $productButtonText = $productButtonPlaceholder.find(".js-addtocart-text"); var $productButtonAdding = $productButtonPlaceholder.find(".js-addtocart-adding"); var $productButtonSuccess = $productButtonPlaceholder.find(".js-addtocart-success"); var isQuickShop = $productContainer.hasClass('js-quickshop-container'); if (!isQuickShop) { if($(".js-product-slide-img.js-active-variant").length) { var imageSrc = $($productContainer.find('.js-product-slide-img.js-active-variant')[0]).data('srcset').split(' ')[0]; } else { var imageSrc = $($productContainer.find('.js-product-slide-img')[0]).attr('srcset').split(' ')[0]; } var quantity = $productContainer.find('.js-quantity-input').val(); var name = $productContainer.find('.js-product-name').text(); var price = $productContainer.find('.js-price-display').text(); var addedToCartCopy = "Agregar al carrito"; } else { var imageSrc = $(this).closest('.js-quickshop-container').find('img').attr('srcset').split(' ')[0]; var quantity = 1; var name = $productContainer.find('.js-item-name').text(); var price = $productContainer.find('.js-price-display').text().trim(); var addedToCartCopy = "Comprar"; if ($productContainer.hasClass("js-quickshop-has-variants")) { var addedToCartCopy = "Agregar al carrito"; }else{ var addedToCartCopy = "Comprar"; } } if (!$(this).hasClass('contact')) { e.preventDefault(); $productButton.hide(); $productButtonPlaceholder.css('display' , 'inline-block'); $productButtonText.fadeOut(); $productButtonAdding.addClass("active"); var callback_add_to_cart = function(){ $(".js-cart-widget-amount").addClass("swing"); setTimeout(function(){ $(".js-cart-widget-amount").removeClass("swing"); },6000); $('.js-cart-notification-item-img').attr('srcset', imageSrc); $('.js-cart-notification-item-name').text(name); $('.js-cart-notification-item-quantity').text(quantity); $('.js-cart-notification-item-price').text(price); if($productVariants.length){ var output = []; $productVariants.each( function(){ var variants = $(this); output.push(variants.val()); }); $(".js-cart-notification-item-variant-container").show(); $(".js-cart-notification-item-variant").text(output.join(', ')) }else{ $(".js-cart-notification-item-variant-container").hide(); } var cartItemsAmount = $(".js-cart-widget-amount").first().text(); if(cartItemsAmount > 1){ $(".js-cart-counts-plural").show(); $(".js-cart-counts-singular").hide(); }else{ $(".js-cart-counts-singular").show(); $(".js-cart-counts-plural").hide(); } $productButtonAdding.removeClass("active"); $productButtonSuccess.addClass("active"); setTimeout(function(){ $productButtonSuccess.removeClass("active"); $productButtonText.fadeIn(); },2000); setTimeout(function(){ $productButtonPlaceholder.removeAttr("style").hide(); $productButton.show(); },3000); $productContainer.find(".js-added-to-cart-product-message").slideDown(); setTimeout(function(){ $(".js-alert-added-to-cart").show().addClass("notification-visible").removeClass("notification-hidden"); },500); if (!cookieService.get('first_product_added_successfully')) { cookieService.set('first_product_added_successfully', 1, 7 ); } else{ setTimeout(function(){ $(".js-alert-added-to-cart").removeClass("notification-visible").addClass("notification-hidden"); setTimeout(function(){ $('.js-cart-notification-item-img').attr('src', ''); $(".js-alert-added-to-cart").hide(); },2000); },8000); } if ($("#product-shipping-container .js-shipping-input").val()) { zipcode_on_addtocart = $("#product-shipping-container .js-shipping-input").val(); $("#cart-shipping-container .js-shipping-input").val(zipcode_on_addtocart); $(".js-shipping-calculator-current-zip").text(zipcode_on_addtocart); } else if (cookieService.get('calculator_zipcode')){ var zipcode_from_cookie = cookieService.get('calculator_zipcode'); $('.js-shipping-input').val(zipcode_from_cookie); $(".js-shipping-calculator-current-zip").text(zipcode_from_cookie); } } var callback_error = function(){ $productButtonAdding.removeClass("active"); $productButtonText.fadeIn(); $productButtonPlaceholder.removeAttr("style").hide(); $productButton.show(); } $prod_form = $(this).closest("form"); LS.addToCartEnhanced( $prod_form, addedToCartCopy, 'Agregando...', '¡Uy! No tenemos más stock de este producto para agregarlo al carrito.', false, callback_add_to_cart, callback_error ); } }); $(document).on("keypress", ".js-cart-quantity-input", function (e) { if (e.which != 8 && e.which != 0 && (e.which 57)) { return false; } }); $(document).on("focusout", ".js-cart-quantity-input", function (e) { var itemID = $(this).attr("data-item-id"); var itemVAL = $(this).val(); if (itemVAL == 0) { var r = confirm("¿Seguro que quieres borrar este artículo?"); if (r == true) { LS.removeItem(itemID, true); } else { $(this).val(1); } } else { LS.changeQuantity(itemID, itemVAL, true); } }); $(".js-trigger-empty-cart-alert").click(function (e) { e.preventDefault(); $(".js-mobile-nav-empty-cart-alert").fadeIn(100).delay(1500).fadeOut(500); }); $('form[action="\x2Fcomprar\x2F"]').submit(function() { cookieService.remove('first_product_added_successfully'); }); if ($('.js-selected-shipping-method').length) { var shipping_cost = $('.js-selected-shipping-method').data("cost"); var $shippingCost = $("#shipping-cost"); $shippingCost.text(shipping_cost); $shippingCost.removeClass('opacity-40'); } selectShippingOption = function(elem, save_option) { $(".js-shipping-method, .js-branch-method").removeClass('js-selected-shipping-method'); $(elem).addClass('js-selected-shipping-method'); var shipping_cost = $(elem).data("cost"); var shipping_price_clean = $(elem).data("price"); if(shipping_price_clean = 0.00){ var shipping_cost = '' } // Updates shipping (ship and pickup) cost on cart var $shippingCost = $("#shipping-cost"); $shippingCost.text(shipping_cost); $shippingCost.removeClass('opacity-40'); if (save_option) { LS.saveCalculatedShipping(true); } if ($(elem).hasClass("js-shipping-method-hidden")) { if ($(elem).hasClass("js-pickup-option")) { $(".js-other-pickup-options, .js-show-other-pickup-options .js-shipping-see-less").show(); $(".js-show-other-pickup-options .js-shipping-see-more").hide(); } else { $(".js-other-shipping-options, .js-show-more-shipping-options .js-shipping-see-less").show(); $(".js-show-more-shipping-options .js-shipping-see-more").hide() } } }; if (cookieService.get('calculator_zipcode')) { var zipcode_from_cookie = cookieService.get('calculator_zipcode'); $('#product-shipping-container .js-shipping-input').val(zipcode_from_cookie); $(".js-shipping-calculator-current-zip").text(zipcode_from_cookie); $(".js-shipping-calculator-head").addClass("with-zip").removeClass("with-form"); $(".js-shipping-calculator-with-zipcode").addClass("transition-up-active"); $(".js-shipping-calculator-spinner").show(); } else { $(".js-shipping-calculator-form").addClass("transition-up-active"); } removeShippingSuboptions = function(){ var shipping_suboptions_id = $(".js-modal-shipping-suboptions").attr("id"); $("#" + shipping_suboptions_id).remove(); $('.js-modal-overlay[data-modal-id="#' + shipping_suboptions_id + '"').remove(); }; $(".js-calculate-shipping").click(function (e) { e.preventDefault(); let shipping_input_val = $(this).closest(".js-shipping-calculator-form").find(".js-shipping-input").val(); $(".js-shipping-input").val(shipping_input_val); if ($(".js-cart-item").length) { LS.calculateShippingAjax( $('#cart-shipping-container').find(".js-shipping-input").val(), '\x2Fenvio\x2F', $("#cart-shipping-container").closest(".js-shipping-calculator-container") ); } $(".js-shipping-calculator-current-zip").html(shipping_input_val); removeShippingSuboptions(); }); $(".js-shipping-input").keydown(function (e) { var key = e.which ? e.which : e.keyCode; var enterKey = 13; if (key === enterKey) { e.preventDefault(); $(this).closest(".js-shipping-calculator-form").find(".js-calculate-shipping").click(); if ($(window).width()