',(i=document.implementation.createHTMLDocument("")).body.innerHTML=t,Array.from(i.body.children)[0]),this.el.parentNode.insertBefore(this.container,this.el),this.container.appendChild(this.el),this.container.style.overflow="hidden",this.container.style.position="relative",this.el.style.webkitTransformOrigin="0% 0%",this.el.style.mozTransformOrigin="0% 0%",this.el.style.msTransformOrigin="0% 0%",this.el.style.oTransformOrigin="0% 0%",this.el.style.transformOrigin="0% 0%",this.el.style.position="absolute"},end:function(){this.hasInteraction=!1,this.sanitize(),this.update()},bindEvents:function(){var t=this;n(this.container,this),window.addEventListener("resize",this.update.bind(this)),Array.from(this.el.querySelectorAll("img")).forEach((function(i){i.addEventListener("load",t.update.bind(t))})),"IMG"===this.el.nodeName&&this.el.addEventListener("load",this.update.bind(this))},update:function(t){this.updatePlaned||(this.updatePlaned=!0,window.setTimeout(function(){this.updatePlaned=!1,this.updateAspectRatio(),t&&"resize"===t.type&&this.computeInitialOffset(),t&&"load"===t.type&&this.setupInitialOffset();var i=this.getInitialZoomFactor()*this.zoomFactor,e=-this.offset.x/i,n=-this.offset.y/i,o="scale3d("+i+", "+i+",1) translate3d("+e+"px,"+n+"px,0px)",s="scale("+i+", "+i+") translate("+e+"px,"+n+"px)",a=function(){this.clone&&(this.clone.parentNode.removeChild(this.clone),delete this.clone)}.bind(this);!this.options.use2d||this.hasInteraction||this.inAnimation?(this.is3d=!0,a(),this.el.style.webkitTransform=o,this.el.style.mozTransform=s,this.el.style.msTransform=s,this.el.style.oTransform=s,this.el.style.transform=o):(this.is3d&&(this.clone=this.el.cloneNode(!0),this.clone.style.pointerEvents="none",this.container.appendChild(this.clone),window.setTimeout(a,200)),this.el.style.webkitTransform=s,this.el.style.mozTransform=s,this.el.style.msTransform=s,this.el.style.oTransform=s,this.el.style.transform=s,this.is3d=!1)}.bind(this),0))},enable:function(){this.enabled=!0},disable:function(){this.enabled=!1}};var n=function(t,i){var e=null,n=0,o=null,s=null,a=function(t,n){if(e!==t){if(e&&!t)switch(e){case"zoom":i.handleZoomEnd(n);break;case"drag":i.handleDragEnd(n)}switch(t){case"zoom":i.handleZoomStart(n);break;case"drag":i.handleDragStart(n)}}e=t},r=function(t){2===n?a("zoom"):1===n&&i.canDrag()?a("drag",t):a(null,t)},h=function(t){return Array.from(t).map((function(t){return{x:t.pageX,y:t.pageY}}))},f=function(t,i){var e,n;return e=t.x-i.x,n=t.y-i.y,Math.sqrt(e*e+n*n)},l=function(t){t.stopPropagation(),t.preventDefault()},c=!0;t.addEventListener("touchstart",(function(t){i.enabled&&(c=!0,n=t.touches.length,function(t){var s=(new Date).getTime();if(n>1&&(o=null),s-o<300)switch(l(t),i.handleDoubleTap(t),e){case"zoom":i.handleZoomEnd(t);break;case"drag":i.handleDragEnd(t)}else i.isDoubleTap=!1;1===n&&(o=s)}(t))})),t.addEventListener("touchmove",(function(t){if(i.enabled&&!i.isDoubleTap){if(c)r(t),e&&l(t),s=h(t.touches);else{switch(e){case"zoom":i.handleZoom(t,function(t,i){var e=f(t[0],t[1]);return f(i[0],i[1])/e}(s,h(t.touches)));break;case"drag":i.handleDrag(t)}e&&(l(t),i.update())}c=!1}})),t.addEventListener("touchend",(function(t){i.enabled&&(n=t.touches.length,r(t))}))};return t}();t.default=e}));
// Move to our_content
window.urls = {
"shippingUrl": "\/envio\/"
}
window.lazySizesConfig = window.lazySizesConfig || {};
lazySizesConfig.hFac = 0.1;
DOMContentLoaded.addEventOrExecute(() => {
jQueryNuvem(document).on("click", ".js-accordion-toggle", function(e) {
e.preventDefault();
if(jQueryNuvem(this).hasClass("js-accordion-show-only")){
jQueryNuvem(this).hide();
}else{
jQueryNuvem(this).find(".js-accordion-toggle-inactive").toggle();
jQueryNuvem(this).find(".js-accordion-toggle-active").toggle();
}
jQueryNuvem(this).prev(".js-accordion-container").slideToggle();
});
jQueryNuvem(document).on("click", ".js-card-collapse-toggle", function(e) {
e.preventDefault();
jQueryNuvem(this).toggleClass('active');
jQueryNuvem(this).closest(".js-card-collapse").toggleClass('active').find(".js-card-body").slideToggle("fast");
jQueryNuvem(this).closest(".js-card-collapse").find(".js-card-collapse-plus, .js-card-collapse-minus").toggle();
});
var $modal_close = jQueryNuvem('.js-modal-close');
var $modal_open = jQueryNuvem('.js-modal-open');
var $modal_overlay = jQueryNuvem('.js-modal-overlay');
$modal_open.on("click", function (e) {
e.preventDefault();
var $modal_id = jQueryNuvem(e.currentTarget).data('toggle');
jQueryNuvem("body").toggleClass("overflow-none modal-active");
if (jQueryNuvem($modal_id).hasClass("modal-show")) {
let modal = jQueryNuvem($modal_id).removeClass("modal-show");
setTimeout(() => modal.hide(), 200);
} else {
jQueryNuvem($modal_id).show().addClass("modal-show");
}
});
$modal_close.on("click", function (e) {
e.preventDefault();
jQueryNuvem("body").toggleClass("overflow-none modal-active");
let modal = jQueryNuvem(e.currentTarget).closest(".js-modal").removeClass("modal-show");
setTimeout(() => modal.hide(), 200);
});
$modal_overlay.on("click", function (e) {
e.preventDefault();
jQueryNuvem("body").toggleClass("overflow-none modal-active");
let modal = jQueryNuvem(".js-modal").removeClass("modal-show");
setTimeout(() => modal.hide(), 200);
});
openModalAbove = function (modal_id){
jQueryNuvem(modal_id).detach().insertAfter(".modal-backdrop");
jQueryNuvem(".modal-backdrop").addClass("modal-backdrop-zindex-top");
};
jQueryNuvem(document).on("click", ".js-trigger-modal-zindex-top", function (e) {
e.preventDefault();
var modal_id = jQueryNuvem(this).attr("href");
openModalAbove(modal_id);
});
if (window.innerWidth < 768) {
jQueryNuvem(document).on("click", ".js-cross-selling-modal-close", function(e) {
jQueryNuvem(".js-ajax-backdrop").hide();
});
jQueryNuvem(document).on("click", ".modal-backdrop", function (e) {
jQueryNuvem(this).next(".js-modal-xs-centered").modal('toggle');
});
cleanURLHash = function(){
const uri = window.location.toString();
const clean_uri = uri.substring(0, uri.indexOf("#"));
window.history.replaceState({}, document.title, clean_uri);
};
goBackBrowser = function(){
cleanURLHash();
history.back();
};
if(window.location.href.indexOf("modal-fullscreen") > -1) {
cleanURLHash();
}
jQueryNuvem(document).on("click", ".js-fullscreen-modal-open", function(e) {
e.preventDefault();
var modal_url_hash = jQueryNuvem(this).data("modalUrl");
window.location.hash = modal_url_hash;
});
jQueryNuvem(document).on("click", ".js-fullscreen-modal-close", function(e) {
e.preventDefault();
goBackBrowser();
});
window.onhashchange = function() {
if(window.location.href.indexOf("modal-fullscreen") <= -1) {
jQueryNuvem("body").removeClass("overflow-none");
if(jQueryNuvem(".js-fullscreen-modal").hasClass("modal-xs-right-in")){
jQueryNuvem(".js-fullscreen-modal.modal-xs-right-in").toggleClass("modal-xs-right-in modal-xs-right-out");
setTimeout(function() {
jQueryNuvem(".js-fullscreen-modal.modal-xs-right-in").hide();
}, 300);
}else if(jQueryNuvem(".js-fullscreen-modal").hasClass("in")){
jQueryNuvem(".js-fullscreen-modal.in").modal('hide');
}
}
}
}
var $notification_status_page = jQueryNuvem(".js-notification-status-page");
var $fixed_bottom_button = jQueryNuvem(".js-btn-fixed-bottom");
var header_height = jQueryNuvem(".js-desktop-head-container").outerHeight();
var header_second_row_height = jQueryNuvem(".js-mobile-head-second-row").outerHeight();
var addbar_height = jQueryNuvem(".js-addbar").outerHeight();
var notification_offset = header_height - header_second_row_height;
jQueryNuvem(".js-alert-added-to-cart").css("top" , (notification_offset - 12).toString() + 'px');
jQueryNuvem(".js-notification-close, .js-tooltip-close").on( "click", function(e) {
e.preventDefault();
jQueryNuvem(e.currentTarget).closest(".js-notification, .js-tooltip").hide();
});
if ($notification_status_page.length > 0){
if (LS.shouldShowOrderStatusNotification($notification_status_page.data('url'))){
$notification_status_page.show();
};
jQueryNuvem(".js-notification-status-page-close").on( "click", function(e) {
e.preventDefault();
LS.dontShowOrderStatusNotificationAgain($notification_status_page.data('url'));
});
}
jQueryNuvem(".js-cart-notification-close").on("click", function(){
jQueryNuvem(".js-alert-added-to-cart").removeClass("notification-visible").addClass("notification-hidden");
setTimeout(function(){
jQueryNuvem('.js-cart-notification-item-img').attr('src', '');
jQueryNuvem(".js-alert-added-to-cart").hide();
},2000);
});
jQueryNuvem(".js-dismiss-quicklogin").on( "click", function(e) {
LS.dontShowQuickLoginNotification();
});
const footerLegal = jQueryNuvem(".js-footer-legal");
restoreNotifications = function(){
// Whatsapp button position
$fixed_bottom_button.css("marginBottom", "10px");
footerLegal.removeAttr("style");
};
if (!window.cookieNotificationService.isAcknowledged()) {
jQueryNuvem(".js-notification-cookie-banner").show();
const cookieBannerHeight = jQueryNuvem(".js-notification-cookie-banner").outerHeight();
footerLegal.css("paddingBottom", cookieBannerHeight + 5 + "px");
if (window.innerWidth < 768) {
$fixed_bottom_button.css("marginBottom", "110px");
}else{
$fixed_bottom_button.css("marginBottom", "50px");
}
}
jQueryNuvem(".js-acknowledge-cookies").on( "click", function(e) {
window.cookieNotificationService.acknowledge();
restoreNotifications();
});
var $top_nav = jQueryNuvem(".js-mobile-nav");
var $page_main_content = jQueryNuvem(".js-main-content");
var $mobile_categories_btn = jQueryNuvem(".js-toggle-mobile-categories");
var $main_categories_mobile_container = jQueryNuvem(".js-categories-mobile-container");
var $search_backdrop = jQueryNuvem(".js-search-backdrop");
// Mobile search
jQueryNuvem(".js-toggle-mobile-search").on("click", function (e) {
e.preventDefault;
var $mobile_tab_navigation = jQueryNuvem(".js-mobile-nav-second-row");
jQueryNuvem(".js-mobile-first-row").toggle();
jQueryNuvem(".js-mobile-search-row").toggle();
$mobile_tab_navigation.toggle();
jQueryNuvem(".js-search-input").val();
$search_backdrop.toggle().toggleClass("search-open");
if (!jQueryNuvem("body").hasClass("mobile-categories-visible")) {
jQueryNuvem("body").toggleClass("overflow-none");
} else {
jQueryNuvem("body").removeClass("mobile-categories-visible");
}
$main_categories_mobile_container.hide();
if ($page_main_content.hasClass("move-up")) {
$page_main_content.removeClass("move-up").addClass("move-down");
$search_backdrop.removeClass("move-up").addClass("move-down");
setTimeout(function () {
$page_main_content.removeClass("move-down");
}, 200);
} else {
$page_main_content.removeClass("move-down").addClass("move-up");
$search_backdrop.removeClass("move-down").addClass("move-up");
}
if ($mobile_categories_btn.hasClass("selected")) {
$mobile_categories_btn.removeClass("selected");
jQueryNuvem(".js-current-page").addClass("selected");
}
});
var $mobile_search_input = jQueryNuvem(".js-mobile-search-input");
jQueryNuvem(".js-toggle-mobile-search-open").on("click", function (e) {
e.preventDefault;
$mobile_search_input.each((el) => el.focus());
});
jQueryNuvem(".js-search-back-btn").on("click", function (e) {
jQueryNuvem(".js-search-suggest").hide();
$mobile_search_input.val('');
});
$top_nav.addClass("move-down").removeClass("move-up");
$mobile_categories_btn.on("click", function (e) {
e.preventDefault();
jQueryNuvem("body").toggleClass("overflow-none mobile-categories-visible");
if ($mobile_categories_btn.hasClass("selected")) {
$mobile_categories_btn.removeClass("selected");
jQueryNuvem(".js-current-page").addClass("selected");
} else {
$mobile_categories_btn.addClass("selected");
jQueryNuvem(".js-current-page").removeClass("selected");
}
$main_categories_mobile_container.toggle();
if ($top_nav.hasClass("move-up")) {
$main_categories_mobile_container.toggleClass("move-list-up");
}
});
jQueryNuvem(".js-open-mobile-subcategory").on("click", function (e) {
e.preventDefault();
var $this = jQueryNuvem(e.currentTarget);
var this_link_id_val = $this.data("target");
var $subcategories_panel_to_be_visible = $this.closest(".js-categories-mobile-container").find("#" + this_link_id_val);
$subcategories_panel_to_be_visible.detach().insertAfter(".js-categories-mobile-container > .js-mobile-nav-subcategories-panel:last-child");
$subcategories_panel_to_be_visible.addClass("modal-xs-right-out").show();
setTimeout(function () {
$subcategories_panel_to_be_visible.toggleClass("modal-xs-right-in modal-xs-right-out");
}, 100);
});
jQueryNuvem(".js-go-back-mobile-categories").on("click", function (e) {
e.preventDefault();
var $this = jQueryNuvem(e.currentTarget);
var $subcategories_panel_to_be_closed = $this.closest(".js-mobile-nav-subcategories-panel");
jQueryNuvem(".js-mobile-nav-subcategories-panel").prop("scrollTop");
$subcategories_panel_to_be_closed.toggleClass("modal-xs-right-in modal-xs-right-out");
setTimeout(function () {
$subcategories_panel_to_be_closed.removeClass("modal-xs-right-out").hide();
}, 300);
});
jQueryNuvem(".js-toggle-page-accordion").on("click", function (e) {
e.preventDefault();
jQueryNuvem(e.currentTarget).toggleClass("selected").closest(".js-hamburger-panel-toggle-accordion").next(".js-pages-accordion").slideToggle(300);
});
var didScroll;
var lastScrollTop = 0;
var delta = 20;
var logoHeight = jQueryNuvem(".js-desktop-head-container").outerHeight();
var navbarHeight = jQueryNuvem('.js-mobile-nav').outerHeight();
var moveNavOffset = logoHeight + navbarHeight + addbar_height;
window.addEventListener("scroll", function (event) {
didScroll = true;
});
setInterval(function () {
if (didScroll) {
hasScrolled();
didScroll = false;
}
}, 250);
var top_head = jQueryNuvem(".js-head-fixed").position().top;
window.addEventListener("scroll", function(){
var position = window.pageYOffset;
var height_head = jQueryNuvem(".js-head-fixed").height();
if(position > top_head){
jQueryNuvem(".js-head-fixed").addClass('head-fix');
jQueryNuvem(".js-body-position").css("paddingTop", height_head.toString() + 'px');
} else {
jQueryNuvem(".js-head-fixed").removeClass('head-fix');
jQueryNuvem(".js-body-position").css("paddingTop", "0px");
}
});
var $category_controls = jQueryNuvem(".js-category-controls");
function hasScrolled() {
var st = window.pageYOffset;
// Make sure they scroll more than delta
if (Math.abs(lastScrollTop - st) <= delta)
return;
// If they scrolled down and are past the navbar, add class .move-up.
if (st > lastScrollTop && st > moveNavOffset) {
// Scroll Down
if (!jQueryNuvem("body").hasClass("mobile-categories-visible")) {
$top_nav.addClass("move-up").removeClass("move-down");
}
jQueryNuvem(".backdrop").addClass("move-up").removeClass("move-down");
} else {
// Scroll Up
let documentHeight = Math.max(
document.body.scrollHeight,
document.body.offsetHeight,
document.documentElement.clientHeight,
document.documentElement.scrollHeight,
document.documentElement.offsetHeight
);
if (st + window.innerHeight < documentHeight) {
if (!jQueryNuvem("body").hasClass("mobile-categories-visible")) {
$top_nav.removeClass("move-up").addClass("move-down");
}
jQueryNuvem(".backdrop").removeClass("move-up").addClass("move-down");
}
}
lastScrollTop = st;
}
LS.search(jQueryNuvem(".js-search-input"), function (html, count) {
$search_suggests = jQueryNuvem(this).closest(".js-search-container").next(".js-search-suggest");
if (count > 0) {
$search_suggests.html(html).show();
} else {
$search_suggests.hide();
}
if (jQueryNuvem(this).val().length == 0) {
$search_suggests.hide();
}
}, {
snipplet: 'search-results.tpl'
});
if (window.innerWidth > 768) {
jQueryNuvem("body").on("click", function () {
jQueryNuvem(".js-search-suggest").hide();
});
jQueryNuvem(document).on("click", ".js-search-suggest a", function () {
jQueryNuvem(".js-search-suggest").show();
});
}
jQueryNuvem(".js-search-suggest").on("click", ".js-search-suggest-all-link", function (e) {
e.preventDefault();
$this_closest_form = jQueryNuvem(this).closest(".js-search-suggest").prev(".js-search-form");
$this_closest_form.submit();
});
LS.newsletter_avoid_siteblindado_bot();
var $newspopup_mandatory_field = jQueryNuvem('#news-popup-form').find(".js-mandatory-field");
const noStockVariants = (container = null) => {
const config = {
variantsGroup: ".js-product-variants-group",
variantButton: ".js-insta-variant",
noStockClass: "btn-variant-no-stock",
dataVariationId: "data-variation-id",
dataOption: "data-option"
};
const wrapper = container ? container : jQueryNuvem('#single-product-container');
if (!wrapper) return;
const dataVariants = wrapper.data('variants');
const variantsLength = wrapper.find(config.variantsGroup).length;
const getOptions = (productVariationId, variantOption) => {
if (productVariationId === 2) {
return {
option0: String(wrapper.find(`${config.variantsGroup}[${config.dataVariationId}="0"] select`).val()),
option1: String(wrapper.find(`${config.variantsGroup}[${config.dataVariationId}="1"] select`).val()),
option2: String(jQueryNuvem(variantOption).attr('data-option')),
};
} else if (productVariationId === 1) {
return {
option0: String(wrapper.find(`${config.variantsGroup}[${config.dataVariationId}="0"] select`).val()),
option1: String(jQueryNuvem(variantOption).attr('data-option')),
};
} else {
return {
option0: String(jQueryNuvem(variantOption).attr('data-option')),
};
}
};
const filterVariants = (options) => {
return dataVariants.filter(variant => {
return Object.keys(options).every(optionKey => variant[optionKey] === options[optionKey]) && variant.available;
});
};
const updateStockStatus = (productVariationId) => {
const variationGroup = wrapper.find(`${config.variantsGroup}[${config.dataVariationId}="${productVariationId}"]`);
variationGroup.find(`${config.variantButton}.${config.noStockClass}`).removeClass(config.noStockClass);
variationGroup.find(config.variantButton).each((variantOption, item) => {
const options = getOptions(productVariationId, variantOption);
const itemsAvailable = filterVariants(options);
const button = wrapper.find(`${config.variantsGroup}[${config.dataVariationId}="${productVariationId}"] ${config.variantButton}[${config.dataOption}="${options[`option${productVariationId}`].replace(/"/g, '\\"')}"]`);
if (!itemsAvailable.length) {
button.addClass(config.noStockClass);
}
});
};
for (let productVariationId = variantsLength - 1; productVariationId >= 0; productVariationId--) {
updateStockStatus(productVariationId);
}
};
noStockVariants();
function get_max_installments_without_interests(number_of_installment, installment_data, max_installments_without_interests) {
if (parseInt(number_of_installment) > 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){
jQueryNuvem(".js-modal-installment-price" ).each(function( el ) {
const installment = Number(jQueryNuvem(el).data('installment'));
jQueryNuvem(el).text(LS.currency.display_short + (price/installment).toLocaleString('de-DE', {maximumFractionDigits: 2, minimumFractionDigits: 2}));
});
}
function refreshPaymentDiscount(price){
jQueryNuvem(".js-price-with-discount" ).each(function( el ) {
const payment_discount = jQueryNuvem(el).data('paymentDiscount');
jQueryNuvem(el).text(LS.formatToCurrency(price - ((price * payment_discount) / 100)))
});
}
function togglePaymentDiscounts(variant){
jQueryNuvem(".js-payment-method-total").each(function( paymentMethodTotalElement ){
const priceComparerElement = jQueryNuvem(paymentMethodTotalElement).find(".js-compare-price-display");
const installmentsOnePaymentElement = jQueryNuvem(paymentMethodTotalElement).find('.js-installments-no-discount');
const priceWithDiscountElement = jQueryNuvem(paymentMethodTotalElement).find('.js-price-with-discount');
priceComparerElement.hide();
installmentsOnePaymentElement.hide();
priceWithDiscountElement.hide();
const discount = priceWithDiscountElement.data('paymentDiscount');
if (discount > 0 && showMaxPaymentDiscount(variant)){
priceComparerElement.show();
priceWithDiscountElement.show()
} else {
installmentsOnePaymentElement.show();
}
})
}
function updateDiscountDisclaimers(variant){
updateProductDiscountDisclaimer(variant);
updatePopupDiscountDisclaimers(variant);
}
function updateProductDiscountDisclaimer(variant){
jQueryNuvem(".js-product-discount-container, .js-product-discount-disclaimer").hide();
if (showMaxPaymentDiscount(variant)){
jQueryNuvem(".js-product-discount-container").show();
}
if (showMaxPaymentDiscountNotCombinableDisclaimer(variant)){
jQueryNuvem(".js-product-discount-disclaimer").show();
}
}
function updatePopupDiscountDisclaimers(variant){
jQueryNuvem(".js-modal-tab-discount, .js-payment-method-discount").hide();
if (showMaxPaymentDiscount(variant)){
jQueryNuvem("#method_pago-nube .js-modal-tab-discount").show();
}
jQueryNuvem(".js-info-payment-method-container").each(function(infoPaymentMethodElement){
const infoPaymentMethod = jQueryNuvem(infoPaymentMethodElement)
infoPaymentMethod.find(".js-discount-explanation").hide();
infoPaymentMethod.find(".js-discount-disclaimer").hide();
const priceWithDiscountElement = infoPaymentMethod.find('.js-price-with-discount');
const discount = priceWithDiscountElement.data('paymentDiscount');
if (discount > 0 && showMaxPaymentDiscount(variant)){
infoPaymentMethod.find(".js-discount-explanation").show();
infoPaymentMethod.find(".js-payment-method-discount").show();
}
if (discount > 0 && showMaxPaymentDiscountNotCombinableDisclaimer(variant)){
infoPaymentMethod.find(".js-discount-disclaimer").show();
}
})
}
function variantHasPromotionalPrice(variant) { return variant.compare_at_price_number > variant.price_number }
function showMaxPaymentDiscount(variant) {
return true;
}
function showMaxPaymentDiscountNotCombinableDisclaimer(variant) {
return false
}
function changeVariant(variant){
jQueryNuvem(".js-product-detail .js-shipping-calculator-response").hide();
jQueryNuvem("#shipping-variant-id").val(variant.id);
var parent = jQueryNuvem("body");
if (variant.element){
parent = jQueryNuvem(variant.element);
}
if(parent.hasClass("js-quickshop-container")){
var itemContainer = parent.closest('.js-item-product').closest();
if(itemContainer.hasClass("js-item-slide")){
var parent = jQueryNuvem('.js-swiper-slide-visible .js-quickshop-container[data-quickshop-id="'+quick_id+'"]');
}
noStockVariants(parent);
} else {
noStockVariants();
}
var sku = parent.find('#sku');
if(sku.length) {
sku.text(variant.sku).show();
}
var stock = parent.find('.js-product-stock');
stock.text(variant.stock).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) {
$element.find('.js-installment-total-price').text((variant.price_short).toLocaleString('de-DE', { minimumFractionDigits: 2 }));
} else {
$element.find('.js-installment-total-price').text(LS.currency.display_short + (price * amount).toLocaleString('de-DE', { minimumFractionDigits: 2 }));
}
};
if (variant.installments_data) {
var variant_installments = JSON.parse(variant.installments_data);
var max_installments_without_interests = [0,0];
var max_installments_with_interests = [0,0];
jQueryNuvem('.js-payment-provider-installments-row').hide();
for (let payment_method in variant_installments) {
var paymentMethodId = '#installment_' + payment_method.replace(" ", "_") + '_1';
var minimumInstallmentValue = jQueryNuvem(paymentMethodId).closest('.js-info-payment-method').attr("data-minimum-installment-value");
let installments = variant_installments[payment_method];
for (let number_of_installment in installments) {
let installment_data = installments[number_of_installment];
max_installments_without_interests = get_max_installments_without_interests(number_of_installment, installment_data, max_installments_without_interests);
max_installments_with_interests = get_max_installments_with_interests(number_of_installment, installment_data, max_installments_with_interests);
var installment_container_selector = '#installment_' + payment_method.replace(" ", "_") + '_' + number_of_installment;
if(minimumInstallmentValue <= installment_data.installment_value) {
jQueryNuvem(installment_container_selector).show();
}
if(!parent.hasClass("js-quickshop-container")){
installment_helper(jQueryNuvem(installment_container_selector), number_of_installment, installment_data.installment_value.toFixed(2));
}
}
}
var $installments_container = jQueryNuvem(variant.element + ' .js-max-installments-container .js-max-installments');
var $installments_modal_link = jQueryNuvem(variant.element + ' #btn-installments');
var $payments_module = jQueryNuvem(variant.element + ' .js-product-payments-container');
var $installmens_card_icon = jQueryNuvem(variant.element + ' .js-installments-credit-card-icon');
var installments_to_use = max_installments_without_interests[0] > 1 ? max_installments_without_interests : max_installments_with_interests;
if(installments_to_use[0] <= 1 ) {
$installments_container.hide();
$installments_modal_link.hide();
$payments_module.hide();
$installmens_card_icon.hide();
} else {
$installments_container.show();
$installments_modal_link.show();
$payments_module.show();
$installmens_card_icon.show();
installment_helper($installments_container, installments_to_use[0], installments_to_use[1]);
}
}
if(!parent.hasClass("js-quickshop-container")){
jQueryNuvem('#installments-modal .js-installments-one-payment').text(variant.price_short).attr("data-value", variant.price_number);
}
if (variant.price_short){
parent.find('.js-price-display').text(variant.price_short).show();
parent.find('.js-price-display').attr("content", variant.price_number).data('productPrice', variant.price_number_raw);
parent.find('.js-payment-discount-price-product').text(variant.price_with_payment_discount_short);
parent.find('.js-payment-discount-price-product-container').show();
parent.find('.js-price-without-taxes').text(variant.price_without_taxes);
parent.find('.js-price-without-taxes-container').show();
} else {
parent.find('.js-price-display, .js-payment-discount-price-product-container, .js-price-without-taxes-container').hide();
}
if ((variant.compare_at_price_short) && !(parent.find(".js-price-display").css("display") == "none")) {
parent.find('.js-compare-price-display').text(variant.compare_at_price_short).show();
if(variant.compare_at_price_number > variant.price_number){
const saved_compare_price_money = variant.compare_at_price_number - variant.price_number;
parent.find('.js-offer-saved-money').text(LS.formatToCurrency(saved_compare_price_money));
parent.find(".js-saved-money-message").show();
}else {
parent.find(".js-saved-money-message").hide();
}
} else {
parent.find('.js-compare-price-display, .js-saved-money-message').hide();
}
var button = parent.find('.js-addtocart');
button.removeClass('cart').removeClass('contact').removeClass('nostock');
var $product_shipping_calculator = parent.find("#product-shipping-container");
if (!variant.available){
button.val('Sin stock');
button.addClass('nostock');
button.attr('disabled', 'disabled');
$product_shipping_calculator.hide();
} else if (variant.contact) {
button.val('Consultar precio');
button.addClass('contact');
button.removeAttr('disabled');
$product_shipping_calculator.hide();
} else {
button.val('Agregar al carrito');
button.addClass('cart');
button.removeAttr('disabled');
$product_shipping_calculator.show();
}
const base_price = Number(jQueryNuvem("#price_display").attr("content"));
refreshInstallmentv2(base_price);
refreshPaymentDiscount(variant.price_number);
togglePaymentDiscounts(variant);
updateDiscountDisclaimers(variant);
LS.updateShippingProduct();
zipcode_on_changevariant = jQueryNuvem("#product-shipping-container .js-shipping-input").val();
jQueryNuvem("#product-shipping-container .js-shipping-calculator-current-zip").text(zipcode_on_changevariant);
}
jQueryNuvem(document).on("change", ".js-variation-option", function(e) {
var $parent = jQueryNuvem(this).closest(".js-product-variants");
var $variants_group = jQueryNuvem(this).closest(".js-product-variants-group");
var $quickshop_parent_wrapper = jQueryNuvem(this).closest(".js-quickshop-container");
if($quickshop_parent_wrapper.hasClass("js-quickshop-modal")){
var quick_id = jQueryNuvem(".js-quickshop-opened .js-quickshop-container").data("quickshopId");
}else{
var quick_id = $quickshop_parent_wrapper.data("quickshopId");
}
if($parent.hasClass("js-product-quickshop-variants")){
var $quickshop_parent = jQueryNuvem(this).closest(".js-item-product");
if($quickshop_parent.hasClass("js-item-slide")){
var $quickshop_variant_selector = '.js-swiper-slide-visible .js-quickshop-container[data-quickshop-id="'+quick_id+'"]';
}else{
var $quickshop_variant_selector = '.js-quickshop-container[data-quickshop-id="'+quick_id+'"]';
}
LS.changeVariant(changeVariant, $quickshop_variant_selector);
} else {
LS.changeVariant(changeVariant, '#single-product .js-product-container');
}
var $this_product_container = jQueryNuvem(this).closest(".js-product-container");
if($this_product_container.hasClass("js-quickshop-container")){
var this_quickshop_id = $this_product_container.attr("data-quickshop-id");
var $this_product_container = jQueryNuvem('.js-product-container[data-quickshop-id="'+this_quickshop_id+'"]');
}
var $this_compare_price = $this_product_container.find(".js-compare-price-display");
var $this_price = $this_product_container.find(".js-price-display");
var $installment_container = $this_product_container.find(".js-product-payments-container");
var $installment_text = $this_product_container.find(".js-max-installments-container");
var $this_add_to_cart = $this_product_container.find(".js-prod-submit-form");
// Get the current product discount percentage value
var current_percentage_value = $this_product_container.find(".js-offer-percentage");
// Get the current product price and promotional price
var compare_price_value = $this_compare_price.html();
var price_value = $this_price.html();
// Calculate new discount percentage based on difference between filtered old and new prices
const percentageDifference = window.moneyDifferenceCalculator.percentageDifferenceFromString(compare_price_value, price_value);
if(percentageDifference){
$this_product_container.find(".js-offer-percentage").text(percentageDifference);
$this_product_container.find(".js-offer-label").css("display" , "table");
}
if ($this_compare_price.css("display") == "none" || !percentageDifference) {
$this_product_container.find(".js-offer-label").hide();
}
if ($this_add_to_cart.hasClass("nostock")) {
$this_product_container.find(".js-stock-label").show();
}
else {
$this_product_container.find(".js-stock-label").hide();
}
if ($this_price.css('display') == 'none'){
$installment_container.hide();
$installment_text.hide();
}else{
$installment_text.show();
}
});
jQueryNuvem(document).on("click", ".js-insta-variant", function (e) {
e.preventDefault();
$this = jQueryNuvem(this);
$this.siblings().removeClass("selected");
$this.addClass("selected");
var option_id = $this.attr('data-option');
$selected_option = $this.closest('.js-product-variants-group').find('.js-variation-option option').filter(function (el) {
return el.value == option_id;
});
$selected_option.prop('selected', true).trigger('change');
$this.closest("[class^='variation']").find('.js-insta-variation-label').html(option_id);
});
LS.registerOnChangeVariant(function(variant){
var $item_to_update_image = jQueryNuvem('.js-item-product[data-product-id^="'+variant.product_id+'"].js-swiper-slide-visible');
var $item_to_update_image_cloned = jQueryNuvem('.js-item-product[data-product-id^="'+variant.product_id+'"].js-swiper-slide-visible.swiper-slide-duplicate');
if($item_to_update_image.hasClass("swiper-slide-duplicate")){
var slide_item_index = $item_to_update_image_cloned.attr("data-swiper-slide-index");
var current_image = jQueryNuvem('.js-item-product[data-product-id="'+variant.product_id+'-clone-'+slide_item_index+'" ] .js-item-image');
}else{
var slide_item_index = $item_to_update_image.attr("data-swiper-slide-index");
var current_image = jQueryNuvem('.js-item-product[data-product-id="'+variant.product_id+'"] .js-item-image');
}
const productContainer = jQueryNuvem('.js-item-product[data-product-id="'+variant.product_id+'"]');
current_image.attr('srcset', variant.image_url);
});
jQueryNuvem(document).on("click", ".js-quickshop-modal-open", function (e) {
e.preventDefault();
var $this = jQueryNuvem(this);
if($this.hasClass("js-quickshop-slide")){
jQueryNuvem("#quickshop-modal .js-item-product").addClass("js-swiper-slide-visible js-item-slide");
}
let container = jQueryNuvem(this).closest('.js-quickshop-container');
if (!container.length) return;
noStockVariants(container);
LS.fillQuickshop($this);
if (window.innerWidth < 768) {
var product_image_dimension = jQueryNuvem(this).closest('.js-item-product').find('.js-item-image-padding').attr("style");
jQueryNuvem("#quickshop-modal .js-quickshop-img-padding").attr("style", product_image_dimension);
}
});
restoreQuickshopForm = function(){
jQueryNuvem("#quickshop-modal .js-item-product").removeClass("js-swiper-slide-visible js-item-slide");
jQueryNuvem("#quickshop-modal .js-quickshop-container").attr('data-variants', '').attr('data-quickshop-id', '');
jQueryNuvem("#quickshop-modal .js-item-product").attr('data-product-id', '');
setTimeout(function(){
var $quickshop_form = jQueryNuvem("#quickshop-form").find('.js-product-form');
var $item_form_container = jQueryNuvem(".js-quickshop-opened").find(".js-item-variants");
$quickshop_form.detach().appendTo($item_form_container);
jQueryNuvem(".js-quickshop-opened").removeClass("js-quickshop-opened");
},350);
};
jQueryNuvem('#quickshop-modal').on('hidden.bs.modal', function (event) {
restoreQuickshopForm();
});
var productButttonWidth = jQueryNuvem(".js-addtocart-placeholder-inline").prev(".js-addtocart").innerWidth();
jQueryNuvem(document).on("click", ".js-mobile-vars-btn", function(e) {
jQueryNuvem(this).next(".js-mobile-vars-panel").removeClass('js-var-panel modal-xs-right-out').addClass('js-var-panel modal-xs-right-in');
jQueryNuvem(this).closest(".modal").prop("scrollTop"), "fast";
jQueryNuvem("body").addClass("overflow-none");
});
function closeVarPanel() {
setTimeout(function(){
jQueryNuvem('.js-var-panel').removeClass('js-var-panel modal-xs-right-in').addClass('js-var-panel modal-xs-right-out')}, 300);
jQueryNuvem("body").removeClass("overflow-none");
};
jQueryNuvem(document).on("click", ".js-close-panel", function(e) {
closeVarPanel();
});
jQueryNuvem(".js-quickshop-mobile-vars-property").on( "click", function(e) {
jQueryNuvem(e.currentTarget).closest(".modal").prop("scrollTop", jQueryNuvem(e.currentTarget).closest(".js-mobile-vars").find(".js-mobile-vars-btn").offset().top);
closeVarPanel();
});
jQueryNuvem(document).on( "click", ".js-mobile-vars-property", function(e) {
var selectedoption = jQueryNuvem(this).attr("data-option");
var varname = jQueryNuvem(this).closest(".js-mobile-vars-panel").data("custom");
jQueryNuvem(this).closest(".js-mobile-vars").find(".js-mobile-vars-selected-label").html(selectedoption);
jQueryNuvem(this).closest(".js-product-detail").prop("scrollTop", jQueryNuvem(this).closest(".js-mobile-vars").find(".js-mobile-vars-btn").offset().top);
closeVarPanel();
});
jQueryNuvem(".js-mobile-vars-property").on("click", function(e) {
e.preventDefault();
$this = jQueryNuvem(e.currentTarget);
$this.siblings().removeClass("selected");
$this.addClass("selected");
var option_id = $this.attr('data-option');
$selected_option = $this.closest('.js-mobile-variations-container').find('.js-variation-option option').filter(function(el) {
return el.value == option_id;
});
$selected_option.prop('selected', true).trigger('change');
});
jQueryNuvem('.js-mobile-pinterest-share').on("click", function(e){
e.preventDefault();
jQueryNuvem(".js-pinterest-share a").get()[0].click();
});
function productSliderNav(){
var productSwiper = null;
createSwiper(
'.js-swiper-product',
{
lazy: true,
loop: false,
slideActiveClass: 'js-product-active-image',
pagination: {
el: '.js-swiper-product-pagination',
clickable: true,
},
navigation: {
nextEl: '.js-swiper-product-next',
prevEl: '.js-swiper-product-prev',
},
on: {
init: function () {
jQueryNuvem(".js-product-slider-placeholder, .js-product-detail-loading-icon").hide();
jQueryNuvem(".js-swiper-product").css("visibility", "visible").css("height", "auto");
},
},
},
function(swiperInstance) {
productSwiper = swiperInstance;
}
);
LS.registerOnChangeVariant(function(variant){
var liImage = jQueryNuvem('.js-swiper-product').find("[data-image='"+variant.image+"']");
var selectedPosition = liImage.data('imagePosition');
var slideToGo = parseInt(selectedPosition);
productSwiper.slideTo(slideToGo);
jQueryNuvem(".js-product-slide-img").removeClass("js-active-variant");
liImage.find(".js-product-slide-img").addClass("js-active-variant");
});
jQueryNuvem(".js-product-thumb").on("click", function(e){
e.preventDefault();
var current_thumb_index = jQueryNuvem(e.currentTarget).attr("data-slide-index");
var match_thumb_image = jQueryNuvem('.js-swiper-product').find("[data-image-position='"+current_thumb_index+"']");
var selectedPosition = match_thumb_image.attr("data-image-position");
var slideToGo = parseInt(selectedPosition);
productSwiper.slideTo(slideToGo);
});
}
productSliderNav ()
createSwiper('.js-swiper-product-thumbnails', {
spaceBetween: 10,
direction: 'vertical',
slidesPerView: 'auto',
threshold: 5,
navigation: {
nextEl: '.js-swiper-product-thumbnails-next',
prevEl: '.js-swiper-product-thumbnails-prev',
},
});
window.addEventListener("load", function () {
product_left_col_height = jQueryNuvem(".js-product-left-col").outerHeight();
if ((window.innerWidth > 768) && (product_left_col_height > 900)) {
// Calculate distance to fix CTA after scroll
affix_top_offset = (jQueryNuvem(".js-desktop-head-container").height() + jQueryNuvem(".js-product-breadcrumbs-container").outerHeight() + jQueryNuvem(".js-product-name-price-container").outerHeight() + jQueryNuvem(".js-product-promo-container").outerHeight() + jQueryNuvem(".js-product-payments-container").outerHeight() + jQueryNuvem(".js-product-quantity-container").outerHeight() + jQueryNuvem(".js-product-buy-container").outerHeight() + jQueryNuvem(".js-product-shipping-container").outerHeight() + jQueryNuvem(".js-product-variants").outerHeight());
// Fix CTA after scroll
jQueryNuvem('.js-product-buy-container').affix({
offset: {
top: affix_top_offset
}
});
// Ghost button placeholder to maintain position of elements when CTA is fixed
jQueryNuvem('.js-product-buy-container').on('affix.bs.affix', function(){
jQueryNuvem(".js-product-buy-placeholder").removeClass("hidden").css('marginTop' , '60px');
});
jQueryNuvem('.js-product-buy-container').on('affix-top.bs.affix', function(){
jQueryNuvem(".js-product-buy-placeholder").addClass("hidden");
});
}
});
function setZoomImage(e, element) {
if (window.innerWidth < 767) { return; }
var zoomContainer = element.querySelector('.js-desktop-zoom-big');
zoomContainer.style.backgroundImage = `url('${zoomContainer.getAttribute('data-desktop-zoom')}')`;
}
function zoom(e, element){
if (window.innerWidth < 767) { return; }
var zoomer = element.querySelector('.js-desktop-zoom-big');
var offsetX = e.offsetX ? e.offsetX : 0;
var offsetY = e.offsetY ? e.offsetY : 0;
var x = offsetX / zoomer.offsetWidth * 100;
var y = offsetY / zoomer.offsetHeight * 100;
zoomer.style.backgroundPosition = x + '% ' + y + '%';
}
var desktopZoom = document.querySelectorAll('.js-desktop-zoom');
desktopZoom.forEach(function(element){
element.addEventListener('mouseenter', (event) => setZoomImage(event, element));
element.addEventListener('mousemove', (event) => zoom(event, element));
});
//Save scrolling position for fixed body on Mobile Zoom opened
var scrollPos = document.documentElement.scrollTop;
window.addEventListener("scroll", function(){
scrollPos = document.documentElement.scrollTop;
});
var savedScrollPos = scrollPos;
// Add tap class to product image
if (window.innerWidth < 768) {
jQueryNuvem(".js-image-open-mobile-zoom").addClass("js-open-mobile-zoom");
}
// Mobile zoom open event
jQueryNuvem(".js-open-mobile-zoom").on("click", function(e){
e.preventDefault();
savedScrollPos = scrollPos;
jQueryNuvem('body').css("position", 'fixed').css("top", (-scrollPos).toString() + 'px');
LS.openMobileZoom();
});
// Mobile zoom close event
jQueryNuvem(".js-close-mobile-zoom").on("click", function(e){
e.preventDefault();
LS.closeMobileZoom(150);
});
const itemRelatedSpacing = 0;
// Set loop for related products products sliders
function calculateRelatedLoopVal(sectionSelector) {
let productsAmount = jQueryNuvem(sectionSelector).attr("data-related-amount");
let loopVal = false;
const applyLoop = (window.innerWidth < 768 && productsAmount > 2) || (window.innerWidth > 768 && productsAmount > 4);
if (applyLoop) {
loopVal = true;
}
return loopVal;
}
let alternativeLoopVal = calculateRelatedLoopVal(".js-related-products");
let complementaryLoopVal = calculateRelatedLoopVal(".js-complementary-products");
createSwiper('.js-swiper-related', {
lazy: true,
loop: alternativeLoopVal,
spaceBetween: itemRelatedSpacing,
watchOverflow: true,
centerInsufficientSlides: true,
threshold: 5,
watchSlideProgress: true,
watchSlidesVisibility: true,
slideVisibleClass: 'js-swiper-slide-visible',
slidesPerView: 2,
slidesPerGroup: 2,
pagination: {
el: '.js-swiper-related-pagination',
clickable: true,
},
navigation: {
nextEl: '.js-swiper-related-next',
prevEl: '.js-swiper-related-prev',
},
breakpoints: {
768: {
slidesPerView: 4,
slidesPerGroup: 4,
}
},
});
createSwiper('.js-swiper-complementary', {
lazy: true,
loop: complementaryLoopVal,
spaceBetween: itemRelatedSpacing,
watchOverflow: true,
centerInsufficientSlides: true,
threshold: 5,
watchSlideProgress: true,
watchSlidesVisibility: true,
slideVisibleClass: 'js-swiper-slide-visible',
slidesPerView: 2,
slidesPerGroup: 2,
pagination: {
el: '.js-swiper-complementary-pagination',
clickable: true,
},
navigation: {
nextEl: '.js-swiper-complementary-next',
prevEl: '.js-swiper-complementary-prev',
},
breakpoints: {
768: {
slidesPerView: 4,
slidesPerGroup: 4,
}
},
});
jQueryNuvem(".js-product-form").on("submit", function (e) {
var button = jQueryNuvem(e.currentTarget).find('[type="submit"]');
button.attr('disabled', 'disabled');
if ((button.hasClass('contact')) || (button.hasClass('catalog'))) {
e.preventDefault();
var product_id = jQueryNuvem(e.currentTarget).find("input[name='add_to_cart']").val();
window.location = "\/contacto\/?product=" + product_id;
} else if (button.hasClass('cart')) {
button.val('Agregando...');
}
});
jQueryNuvem(document).on("keypress", ".js-cart-quantity-input", function (e) {
if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
return false;
}
});
jQueryNuvem(document).on("focusout", ".js-cart-quantity-input", function (e) {
var itemID = jQueryNuvem(this).attr("data-item-id");
var itemVAL = jQueryNuvem(this).val();
if (itemVAL == 0) {
var r = confirm("¿Seguro que quieres borrar este artículo?");
if (r == true) {
LS.removeItem(itemID, true);
} else {
jQueryNuvem(this).val(1);
}
} else {
LS.changeQuantity(itemID, itemVAL, true);
}
});
jQueryNuvem(".js-hide-alert").on("click", function(e){
e.preventDefault();
jQueryNuvem(e.currentTarget).closest(".alert").hide();
})
jQueryNuvem(".js-trigger-empty-cart-alert").on("click", function (e) {
e.preventDefault();
let emptyCartAlert = jQueryNuvem(".js-mobile-nav-empty-cart-alert").fadeIn(100);
setTimeout(() => emptyCartAlert.fadeOut(500), 1500);
});
function getQuickShopImgSrc(element){
const image = jQueryNuvem(element).closest('.js-quickshop-container').find('img');
return String(image.attr('srcset'));
}
jQueryNuvem(document).on("click", ".js-addtocart:not(.js-addtocart-placeholder)", function (e) {
var $productContainer = jQueryNuvem(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');
var isCrossSelling = $productContainer.hasClass('js-cross-selling-container');
var quantity = $productContainer.find('.js-quantity-input').val();
if (isCrossSelling) {
var imageSrc = $productContainer.find('.js-cross-selling-product-image').attr('src');
quantity = $productContainer.data('quantity')
var name = $productContainer.find('.js-cross-selling-product-name').text();
var price = $productContainer.find('.js-cross-selling-promo-price').text();
} else if (!isQuickShop) {
if(jQueryNuvem(".js-product-slide-img.js-active-variant").length) {
var imageSrc = $productContainer.find('.js-product-slide-img.js-active-variant').data('srcset').split(' ')[0];
} else {
var imageSrc = $productContainer.find('.js-product-featured-image .js-product-slide-img').data('srcset').split(' ')[0];
}
var name = jQueryNuvem('#product-name').text();
var price = $productContainer.find('.js-price-display').text();
var price = $productContainer.find('.js-product-name-price-container .js-price-display').text().trim();
} else {
var imageSrc = getQuickShopImgSrc(this);
var name = $productContainer.find('.js-item-name').text();
var quantity = 1;
var price = $productContainer.find('.js-price-display').text();
}
if (!jQueryNuvem(this).hasClass('contact')) {
e.preventDefault();
$productButton.hide();
$productButtonPlaceholder.show().addClass("active");
if (isQuickShop) {
$productButtonPlaceholder.width(productButttonWidth-37);
}
$productButtonText.removeClass("active");
setTimeout(function(){
$productButtonAdding.addClass("active");
},300);
var callback_add_to_cart = function(html_notification_related_products, html_notification_cross_selling) {
jQueryNuvem('.js-cart-notification-item-img').attr('srcset', imageSrc);
jQueryNuvem('.js-cart-notification-item-name').text(name);
jQueryNuvem('.js-cart-notification-item-quantity').text(quantity);
jQueryNuvem('.js-cart-notification-item-price').text(price);
if($productVariants.length){
var output = [];
$productVariants.each( function(el){
var variants = jQueryNuvem(el);
output.push(variants.val());
});
jQueryNuvem(".js-cart-notification-item-variant-container").show();
jQueryNuvem(".js-cart-notification-item-variant").text(output.join(', '))
}else{
jQueryNuvem(".js-cart-notification-item-variant-container").hide();
}
$productContainer.find(".js-added-to-cart-product-message").fadeIn();
jQueryNuvem(".js-cart-link").addClass("active");
var cartItemsAmount = jQueryNuvem(".js-cart-widget-amount").text();
if(cartItemsAmount > 1){
jQueryNuvem(".js-cart-counts-plural").show();
jQueryNuvem(".js-cart-counts-singular").hide();
}else{
jQueryNuvem(".js-cart-counts-singular").show();
jQueryNuvem(".js-cart-counts-plural").hide();
}
$productButtonAdding.removeClass("active");
setTimeout(function(){
$productButtonSuccess.addClass("active");
},300);
setTimeout(function(){
$productButtonSuccess.removeClass("active");
setTimeout(function(){
$productButtonText.addClass("active");
},300);
$productButtonPlaceholder.removeClass("active");
},2000);
setTimeout(function(){
$productButtonPlaceholder.hide();
$productButton.show();
},4000);
let notificationWithRelatedProducts = false;
var cartItemsAmount = jQueryNuvem(".js-cart-widget-amount").text();
if(cartItemsAmount > 1){
jQueryNuvem(".js-cart-counts-plural").show();
jQueryNuvem(".js-cart-counts-singular").hide();
}else{
jQueryNuvem(".js-cart-counts-singular").show();
jQueryNuvem(".js-cart-counts-plural").hide();
}
function recommendProductsOnAddToCart(){
jQueryNuvem('.js-related-products-notification-container').html("");
jQueryNuvem("#related-products-notification").modal('show');
openModalAbove("#related-products-notification");
jQueryNuvem('.js-related-products-notification-container').html(html_notification_related_products).show();
// Set loop for recommended products
function calculateRelatedNotificationLoopVal(sectionSelector) {
let productsAmount = jQueryNuvem(sectionSelector).attr("data-related-amount");
let loopVal = false;
const applyLoop = productsAmount > 3;
if (applyLoop) {
loopVal = true;
}
return loopVal;
}
let cartRelatedLoopVal = calculateRelatedNotificationLoopVal(".js-related-products-notification");
// Create new swiper on add to cart
setTimeout(function(){
createSwiper('.js-swiper-related-products-notification', {
lazy: true,
loop: cartRelatedLoopVal,
watchOverflow: true,
threshold: 5,
watchSlideProgress: true,
watchSlidesVisibility: true,
spaceBetween: 15,
slideVisibleClass: 'js-swiper-slide-visible',
slidesPerView: 3,
slidesPerGroup: 3,
navigation: {
nextEl: '.js-swiper-related-products-notification-next',
prevEl: '.js-swiper-related-products-notification-prev',
},
pagination: {
el: '.js-swiper-related-notification-pagination',
clickable: true,
},
});
},200);
}
notificationWithRelatedProducts = html_notification_related_products != null;
if(notificationWithRelatedProducts){
if (isQuickShop) {
setTimeout(function(){
recommendProductsOnAddToCart();
},300);
}else{
recommendProductsOnAddToCart();
}
}
if(!notificationWithRelatedProducts){
if (window.innerWidth > 768) {
if(jQueryNuvem(".js-ajax-cart-panel").css('display') == 'none'){
jQueryNuvem("body").addClass("overflow-none");
}
jQueryNuvem(".js-ajax-cart-panel, .js-ajax-backdrop").toggle();
}else{
setTimeout(function(){
jQueryNuvem(".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(){
jQueryNuvem(".js-alert-added-to-cart").removeClass("notification-visible").addClass("notification-hidden");
setTimeout(function(){
jQueryNuvem('.js-cart-notification-item-img').attr('src', '');
jQueryNuvem(".js-alert-added-to-cart").hide();
},2000);
},8000);
}
if (isQuickShop) {
cleanURLHash();
}
}
}
// set Add to Cart notification content
jQueryNuvem('.js-notification-item-img').attr('src', imageSrc);
jQueryNuvem('.js-notification-item-name').text(name);
jQueryNuvem('.js-notification-item-quantity').text(quantity);
jQueryNuvem('.js-notification-item-price').text(price);
if (html_notification_cross_selling != null) {
jQueryNuvem('.js-cross-selling-modal-body').html("");
jQueryNuvem("#js-cross-selling-modal").modal('show');
if (window.innerWidth < 768) {
jQueryNuvem(".js-ajax-backdrop").show();
}
jQueryNuvem('.js-cross-selling-modal-body').html(html_notification_cross_selling).show();
}
const crossSellingContainer = document.querySelector('.js-cross-selling-container');
if (crossSellingContainer) {
LS.fillCrossSelling(crossSellingContainer);
}
if (jQueryNuvem("#product-shipping-container .js-shipping-input").val()) {
zipcode_on_addtocart = jQueryNuvem("#product-shipping-container .js-shipping-input").val();
jQueryNuvem("#cart-shipping-container .js-shipping-input").val(zipcode_on_addtocart);
jQueryNuvem(".js-shipping-calculator-current-zip").text(zipcode_on_addtocart);
} else if (cookieService.get('calculator_zipcode')){
var zipcode_from_cookie = cookieService.get('calculator_zipcode');
jQueryNuvem('.js-shipping-input').val(zipcode_from_cookie);
jQueryNuvem(".js-shipping-calculator-current-zip").text(zipcode_from_cookie);
}
if (isCrossSelling) {
jQueryNuvem('.js-cross-selling-modal-close').trigger('click');
if (window.innerWidth > 768) {
if (jQueryNuvem(".js-ajax-cart-panel").css('display') == 'none') {
jQueryNuvem("body").addClass("overflow-none");
}
jQueryNuvem(".js-ajax-cart-panel, .js-ajax-backdrop").toggle();
}
}
}
var callback_error = function(){
$productButtonPlaceholder.removeClass("active");
$productButtonText.fadeIn("active");
$productButtonAdding.removeClass("active");
$productButtonPlaceholder.hide();
$productButton.show();
}
$prod_form = jQueryNuvem(this).closest("form");
LS.addToCartEnhanced(
$prod_form,
'Agregar al carrito',
'Agregando...',
'¡Uy! No tenemos más stock de este producto para agregarlo al carrito.',
false,
callback_add_to_cart,
callback_error
);
}
});
const ajax_cart_panel = jQueryNuvem(".js-ajax-cart-panel");
mobileToggleAjaxCart = function(){
if(!jQueryNuvem("body").hasClass("mobile-categories-visible")){
jQueryNuvem("body").toggleClass("overflow-none");
}
if(ajax_cart_panel.hasClass("modal-xs-right-in")){
ajax_cart_panel.toggleClass("modal-xs-right-in modal-xs-right-out");
setTimeout(function() {
ajax_cart_panel.hide();
}, 300);
}else{
ajax_cart_panel.show();
setTimeout(function() {
ajax_cart_panel.toggleClass("modal-xs-right-in modal-xs-right-out");
}, 300);
}
};
jQueryNuvem(document).on("click", ".js-toggle-cart", function (e) {
e.preventDefault();
if (window.innerWidth < 768) {
mobileToggleAjaxCart();
}else{
jQueryNuvem(".js-ajax-backdrop").toggle();
ajax_cart_panel.toggle();
jQueryNuvem("body").toggleClass("overflow-none");
}
});
jQueryNuvem('form[action="\/comprar\/"]').on("submit", function() {
cookieService.remove('first_product_added_successfully');
});
selectShippingOption = function(elem, save_option) {
jQueryNuvem(".js-shipping-method, .js-branch-method").removeClass('js-selected-shipping-method');
jQueryNuvem(elem).addClass('js-selected-shipping-method');
if (save_option) {
LS.saveCalculatedShipping(true);
}
if(jQueryNuvem(elem).hasClass("js-shipping-method-hidden")){
if(jQueryNuvem(elem).hasClass("js-pickup-option")){
jQueryNuvem(".js-other-pickup-options, .js-show-other-pickup-options .js-shipping-see-less").show();
jQueryNuvem(".js-show-other-pickup-options .js-shipping-see-more").hide();
}else{
jQueryNuvem(".js-other-shipping-options, .js-show-more-shipping-options .js-shipping-see-less").show();
jQueryNuvem(".js-show-more-shipping-options .js-shipping-see-more").hide()
}
}
};
if (cookieService.get('calculator_zipcode')) {
var zipcode_from_cookie = cookieService.get('calculator_zipcode');
jQueryNuvem('#product-shipping-container .js-shipping-input').val(zipcode_from_cookie);
jQueryNuvem(".js-shipping-calculator-current-zip").text(zipcode_from_cookie);
jQueryNuvem(".js-shipping-calculator-head").addClass("with-zip").removeClass("with-form");
jQueryNuvem(".js-shipping-calculator-with-zipcode").addClass("transition-up-active");
jQueryNuvem(".js-shipping-calculator-spinner").show();
} else {
jQueryNuvem(".js-shipping-calculator-form").addClass("transition-up-active");
}
removeShippingSuboptions = function(){
var shipping_suboptions_id = jQueryNuvem(".js-modal-shipping-suboptions").attr("id");
jQueryNuvem("#" + shipping_suboptions_id).remove();
jQueryNuvem('.js-modal-overlay[data-modal-id="#' + shipping_suboptions_id + '"').remove();
};
jQueryNuvem(document).on("click", ".js-toggle-branches", function (e) {
e.preventDefault();
jQueryNuvem(".js-store-branches-container").slideToggle("fast");
jQueryNuvem(".js-see-branches, .js-hide-branches").toggle();
});
jQueryNuvem(document).on("change", ".js-shipping-method, .js-branch-method", function (e) {
selectShippingOption(this, true);
jQueryNuvem(".js-shipping-method-unavailable").hide();
});
jQueryNuvem(document).on('shipping.options.checked', '.js-shipping-method', function (e) {
let shippingPrice = jQueryNuvem(this).attr("data-price");
LS.addToTotal(shippingPrice);
let total = (LS.data.cart.total / 100) + parseFloat(shippingPrice);
jQueryNuvem(".js-cart-widget-total").html(LS.formatToCurrency(total));
selectShippingOption(this, false);
});
jQueryNuvem(".js-shipping-input").on("keydown", function (e) {
var key = e.which ? e.which : e.keyCode;
var enterKey = 13;
if (key === enterKey) {
e.preventDefault();
jQueryNuvem(e.currentTarget).parent().find(".js-calculate-shipping").trigger('click');
if (window.innerWidth < 768) {
jQueryNuvem(e.currentTarget).trigger('blur');
}
}
});
jQueryNuvem(".js-calculate-shipping").on("click", function (e) {
e.preventDefault();
let shipping_input_val = jQueryNuvem(e.currentTarget).closest(".js-shipping-calculator-form").find(".js-shipping-input").val();
jQueryNuvem(".js-shipping-input").val(shipping_input_val);
if (!vanillaJS) {
LS.calculateShippingAjax(
jQueryNuvem('#product-shipping-container').find(".js-shipping-input").val(),
'\/envio\/',
jQueryNuvem("#product-shipping-container").closest(".js-shipping-calculator-container") );
}
if (jQueryNuvem(".js-cart-item").length) {
LS.calculateShippingAjax(
jQueryNuvem('#cart-shipping-container').find(".js-shipping-input").val(),
'\/envio\/',
jQueryNuvem("#cart-shipping-container").closest(".js-shipping-calculator-container") );
}
jQueryNuvem(".js-shipping-calculator-current-zip").html(shipping_input_val);
removeShippingSuboptions();
});
jQueryNuvem(document).on("click", ".js-toggle-more-shipping-options", function(e) {
e.preventDefault();
if(jQueryNuvem(this).hasClass("js-show-other-pickup-options")){
jQueryNuvem(".js-other-pickup-options").slideToggle(600);
jQueryNuvem(".js-show-other-pickup-options .js-shipping-see-less, .js-show-other-pickup-options .js-shipping-see-more").toggle();
}else{
jQueryNuvem(".js-other-shipping-options").slideToggle(600);
jQueryNuvem(".js-show-more-shipping-options .js-shipping-see-less, .js-show-more-shipping-options .js-shipping-see-more").toggle();
}
});
calculateCartShippingOnLoad = function(){
if(jQueryNuvem("#cart-shipping-container .js-shipping-input").val()){
// If user already had calculated shipping: recalculate shipping
setTimeout(function() {
LS.calculateShippingAjax(
jQueryNuvem('#cart-shipping-container').find(".js-shipping-input").val(),
'\/envio\/',
jQueryNuvem("#cart-shipping-container").closest(".js-shipping-calculator-container") );
removeShippingSuboptions();
}, 100);
}
if(jQueryNuvem(".js-branch-method").hasClass('js-selected-shipping-method')){
}
};
if(!vanillaJS) {
if(jQueryNuvem('#product-shipping-container').find(".js-shipping-input").val()){
setTimeout(function() {
LS.calculateShippingAjax(
jQueryNuvem('#product-shipping-container').find(".js-shipping-input").val(),
'\/envio\/',
jQueryNuvem("#product-shipping-container").closest(".js-shipping-calculator-container") );
removeShippingSuboptions();
}, 100);
}
}
if (cookieService.get('returning_customer') && LS.shouldShowQuickLoginNotification()) {
jQueryNuvem('.js-product-quick-login').show();
} else {
jQueryNuvem('.js-shipping-zipcode-help').show();
}
jQueryNuvem(document).on("click", ".js-shipping-calculator-change-zipcode", function(e) {
e.preventDefault();
jQueryNuvem(".js-shipping-calculator-response").fadeOut(100);
jQueryNuvem(".js-shipping-calculator-head").addClass("with-form").removeClass("with-zip");
jQueryNuvem(".js-shipping-calculator-with-zipcode").removeClass("transition-up-active");
jQueryNuvem(".js-shipping-calculator-form").addClass("transition-up-active");
});
jQueryNuvem(document).on("click", ".js-save-shipping-country", function(e) {
e.preventDefault();
var selected_country_url = jQueryNuvem(this).closest(".js-modal-shipping-country").find(".js-shipping-country-select option").filter((el) => el.selected).attr("data-country-url");
location.href = selected_country_url;
jQueryNuvem(this).text('Aplicando...').addClass("disabled");
});
jQueryNuvem('.js-password-view').on("click", function (e) {
jQueryNuvem(e.currentTarget).toggleClass('password-view');
if(jQueryNuvem(e.currentTarget).hasClass('password-view')){
jQueryNuvem(e.currentTarget).parent().find(".js-password-input").attr('type', '');
jQueryNuvem(e.currentTarget).find(".js-eye-open, .js-eye-closed").toggle();
} else {
jQueryNuvem(e.currentTarget).parent().find(".js-password-input").attr('type', 'password');
jQueryNuvem(e.currentTarget).find(".js-eye-open, .js-eye-closed").toggle();
}
});
});
});
No se encontraron comentarios para este producto. ¡Sé el primero en comentar!