$('.buy-box-load').hide(); exibeSellers(); var urlCartZipCode = '/cart/'; if(zipCode != ""){ urlCartZipCode = urlCartZipCode+'?zipCode='+zipCode; } new WOW().init(); var a = [], t = new Set([]); "use strict"; var c = '

{VARIANT_NAME}

{VARIANT_PRICE}

{VARIANT_QUANTITY_PRESENTATION}

', d = '
Descontos: {CART_DISCOUNT_TOTAL}
', m = '
' + (SHOW_PRODUCT_PRICE ? 'TOTAL: {CART_TOTAL}' : "") + 'shopping_bag   Ir para o carrinho
'; $("body").on("cart-success", [".flexy-add-to-cart", ".btn-add-to-cart-qty"], function (e, t) { var o = 4e3; var a = $(".cart-sumary .header-mini-cart"); updateCart(t); if($(window).width()>991){ // a.addClass("open"); // window.setTimeout(function () { a.removeClass("open"); }, o) window.location.href = "/cart" } else { alert("Produto adicionado ao carrinho!"); window.location.href = "/cart" } }), $("body").on("cart-error", function (e, t) { alert(t); }); $("body").find(".holder").length || $("body").append("
"); $("div.holder").jPages({ containerID: "products", previous: ".feature-block a[data-role='prev']", next: ".feature-block a[data-role='next']", animation: "fadeInRight", perPage: 4 }); function updateCart(e) { var t = SHOW_PRODUCT_PRICE ? $.number(e.totalWithDiscount, 2, ",", ".") : "", o = $(".shopping-cart-content").empty(), a = (function (e) { var t = []; if ((0 < e.items.length && (t = $.merge(t, e.items)), e.sales && 0 < e.sales.length)) for (var o = 0; o < e.sales.length; o++) t = $.merge(t, e.sales[o].items); return t; })(e); if (e && 0 != a.length) { o.append(m.replace("{CART_TOTAL}", "R$ " + t)); for (var i = 0, s = 0; s < a.length; s++) { var n = a[s], r = SHOW_PRODUCT_PRICE ? "R$ " + $.number(n.totalPriceWithDiscount, 2, ",", ".") : "", l = n.quantity; n.variant.isFractionalStock && (l = 1), o.append( c .replace("{PRODUCT_IMAGE}", n.image ? n.image : "/bundles/flexyftwostore/img/product-placeholder.gif") .replace("{VARIANT_NAME}", n.name) .replace("{VARIANT_PRICE}", r) .replace("{VARIANT_QUANTITY_PRESENTATION}", "Qtd: " + g(n.quantity)) ), (i += l); } 0 < e.salePromotionDiscountTotal && SHOW_PRODUCT_PRICE && o.append(d.replace("{CART_DISCOUNT_TOTAL}", "R$ " + $.number(e.salePromotionDiscountTotal, 2, ",", "."))), window.innerWidth < 991 || screen.width < 991 ? $(".cart-items-count").html('' + Number(i) + "") : $(".cart-items-count").html(Number(i)); } else o.html("

Nenhum produto em seu carrinho.

"); } function g(e) { return -1 < (e = e.toString()).indexOf(".") && (e = (e = Number(e).toFixed(3)).replace(".", ",")), e; } function f() { if ($("[name='customer[type]']").length) { var e = $("[name='customer[type]']").val(), t = $("#customer_customerType"), o = t.find("option"); "cpf" == e ? ($(".cpf").show().find(":input").attr("required", "required"), $(".cnpj").hide().find(":input").removeAttr("required"), t.val( o.filter(function () {return "B2C" == $(this).text();}).val() )) : ($(".cnpj").show().find(":input:not(#check):not(#customer_taxationRegime)").attr("required", "required"), $(".cpf").hide().find(":input").removeAttr("required"), t.val( o.filter(function () { return "B2B" == $(this).text();}).val() )); } } function h(e) { return (e = e.replace(/\./g, "")), parseFloat(e.replace(/,/g, ".")); } function s(e, t) { return !(t && t < e) || (alert("Não foi possível adicionar " + e + " produtos ao carrinho."), !1); // + " Atualmente possuímos apenas " + t } // search controls function searchE() { $(".search-box").animate({ opacity: "toggle" }, 500, function () {}), $(".search-modal-background").animate({ opacity: "toggle" }, 500, function () {}); } $(".search-box-toggle").click(function () { searchE(), $(".search-input").focus(); }); $(".search-modal-background").click(function () { searchE(); }); //general $(".time").countdown({ date: new Date(new Date().getTime() + 864e5), yearsAndMonths: !0, leadingZero: !0 }); $(".ul-side-category li a").click(function () { var e = $(this).next(); return !e.hasClass("sub-category") || ("none" === e.css("display") ? $(this).next().slideDown() : ($(this).next().slideUp(), $(this).next().find(".sub-category").slideUp()), !1); }); $("[name='customer[type]']").on("change blur", function () { f(); }); $("#check").on("change click", function () { $(this).is(":checked") ? $("#customer_cnpj_stateRegistration").addClass("readonly").attr("readonly", "readonly").val("ISENTO") : $("#customer_cnpj_stateRegistration").removeClass("readonly").removeAttr("readonly").val(""); }); $(".main-category-block label").on("click", function () { window.location.href = $(this).data("url"); }); $("#partners img").on("mouseenter", function (e) { var t = $(this); t.data("src", t.attr("src")).attr("src", t.data("hover")); }).on("mouseleave", function (e) { var t = $(this); t.attr("src", t.data("src")); }); $(".flexy-cart-product-quantity, .input-number-inf") .on("focus", function (e) { var t = $(this); t.data("quantity", h(t.val())); }) .on("blur", function (e) { var t = $(this); t.val() && t.val() != t.data("quantity") ? t.trigger("change") : t.val(t.data("quantity")); }); $(".tool_tip").tooltip(); $("#product-zoom").elevateZoom({ zoomType: "inner", cursor: "crosshair", zoomWindowFadeIn: 500, zoomWindowFadeOut: 750 }); $(".stock-verified").on("change keypress keyup keydown", function (e) { var t = $(this); s(Number(t.val()), t.data("stock")) || (t.val(g(t.data("stock"))).trigger("change"), e.preventDefault(), e.stopImmediatePropagation()); }); var w, b = $(".flexy-weight-mask"); b.mask("#######0,000", { placeholder: "0,000", reverse: !0 }); b.on("keyup", function (i) { clearTimeout(w), (w = setTimeout(function () { var e, t, o, a; (e = i), (t = $(this).val()), (o = $(this)), (a = o.data("stock")), (s(h(t), a) || (o.val(g(a)).trigger("change"), e.preventDefault(), e.stopImmediatePropagation(), 0)) && $(this).trigger("blur"); }, 1200)); }), b.on("keydown", function (e) { clearTimeout(w); }) //home var t = 0, o = $("#header"), a = $("#header-main-fixed"), n = $(".header-bg"), r = $(".top-header-bg"), l = document.getElementById("gotop"), u = null != l; $(window).scroll(function () { var e = $(this).scrollTop(); t < e ? 110 < e && (o.addClass("header-top-fixed"), o.find(".header-top-row").addClass("dis-n"), n.addClass("header-bg-fixed"), a.addClass("header-main-fixed"), r.addClass("top-header-bg-fix"), u && (l.style.display = "block")) : e < 110 && (o.removeClass("header-top-fixed"), o.find(".header-top-row").removeClass("dis-n"), a.removeClass("header-main-fixed"), n.removeClass("header-bg-fixed"), r.removeClass("top-header-bg-fix"), u && (l.style.display = "none")), (t = e); }), $(".dropdown").hover( function () { $(this).addClass("open"); }, function () { $(this).removeClass("open"); } ); $('#selectCustomer').select2({ placeholder: ' - selecione um cliente -', }).change(function (e) { e.preventDefault(); var selectedData = $(this).val(); }); $("#selectCustomer").change(function() { var customerId = $(this).val(); if (customerId == "new") { window.location.href = urlCustomerCreate; return; } $.ajax({ url : urlCustomerChange, data : { customerId : customerId }, success : function() { window.location.reload(); }, error : function() { alert("{{ 'store.customerSelectError'|trans }}"); } }); }); //owl carousel $(".product-related-nav .next").click(function () { $($(this).data("carousel")).trigger("owl.next"); }); $(".product-related-nav .prev").click(function () { $($(this).data("carousel")).trigger("owl.prev"); }); $(".top-page").click(function () { (document.body.scrollTop = 0), (document.documentElement.scrollTop = 0); }), $("#nav-tabs .next").click(function () { $("#owl-new").trigger("owl.next"), $("#owl-featured").trigger("owl.next"); }), $("#nav-tabs .prev").click(function () { $("#owl-new").trigger("owl.prev"), $("#owl-featured").trigger("owl.prev"); }), $("#nav-tabs2 .next").click(function () { $("#owl-new2").trigger("owl.next"), $("#owl-featured2").trigger("owl.next"); }), $("#nav-tabs2 .prev").click(function () { $("#owl-new2").trigger("owl.prev"), $("#owl-featured2").trigger("owl.prev"); }), $('.home-product-carousel').owlCarousel({ items: 4, itemsCustom: !1, itemsDesktop: [1199, 4], itemsDesktopSmall: [980, 3], itemsTablet: [768, 2], itemsTabletSmall: !1, itemsMobile: [650, 1], singleItem: !1, itemsScaleUp: !1, responsive: !0, responsiveRefreshRate: 200, responsiveBaseWidth: window, autoPlay: !1, stopOnHover: !1, navigation: true, }); $('.home-product-carousel-seller').owlCarousel({ items: 3, itemsCustom: !1, itemsDesktop: [1199, 3], itemsDesktopSmall: [980, 2], itemsTablet: [768, 2], itemsTabletSmall: !1, itemsMobile: [650, 1], singleItem: !1, itemsScaleUp: !1, responsive: !0, responsiveRefreshRate: 200, responsiveBaseWidth: window, autoPlay: !1, stopOnHover: !1, navigation: true, }); $('.product-related-carousel').owlCarousel({ items: 4, itemsCustom: !1, itemsDesktop: [1199, 4], itemsDesktopSmall: [980, 3], itemsTablet: [768, 2], itemsTabletSmall: !1, itemsMobile: [650, 1], singleItem: !1, itemsScaleUp: !1, responsive: !0, responsiveRefreshRate: 200, responsiveBaseWidth: window, autoPlay: !1, stopOnHover: !1, navigation: true, }); $('#gal1').owlCarousel({ items: 6, itemsCustom: !1, itemsDesktop: [1199, 6], itemsDesktopSmall: [980, 6], itemsTablet: [630, 6], itemsTabletSmall: !1, itemsMobile: [479, 5], singleItem: !1, itemsScaleUp: !1, responsive: !0, responsiveRefreshRate: 200, responsiveBaseWidth: window, autoPlay: !1, stopOnHover: !1, navigation: !1, }); //navigation function filterToggle(){ $(".sidebar-menu").animate({ opacity: "toggle" }, 500, function() { // Animation complete. }); $(".filter-menu-modal-close").animate({ opacity: "toggle" }, 500, function() { // Animation complete. }); } $( ".filter-menu-btn" ).click(function() { $("html").addClass("mobile-html-fix"); $("body").addClass("mobile-body-fix"); $(".top-page").css("display", "block"); filterToggle(); }); $( ".filter-menu-modal-close" ).click(function() { $("html").removeClass("mobile-html-fix"); $("body").removeClass("mobile-body-fix"); $(".top-page").css("display", "none"); filterToggle(); }); /* $(window).resize(function() { if($(window).width() > 992){ $(".sidebar-menu").css("display", "block"); $(".filter-menu-modal-close").css("display", "none"); }else{ $(".sidebar-menu").css("display", "none"); $(".filter-menu-modal-close").css("display", "none"); } }); */ $('.flexy-list-btn').click(function(event){ event.preventDefault(); $('.flexy-display-mode').addClass('flexy-list-display'); }); $('.flexy-grid-btn').click(function(event){ event.preventDefault(); $('.flexy-display-mode').removeClass('flexy-list-display'); }); //product var e = $("#gal1"); e.find("a[data-image]").hover(function () { $(".product-media-details").removeClass("video"); var e = $(this).attr("data-image"), t = $(this).attr("data-zoom-image"); $("#product-zoom").data("elevateZoom").swaptheimage(e, t); }), e.find("a[data-video]").on("mouseover", function () { var e = $(this), t = $(".product-media-details"), o = t.find(".product-video"); o.find("iframe").remove(), o.append('
'); new YT.Player("player", { width: "100%", videoId: e.data("video"), events: { onReady: function (e) { e.target.playVideo(); }, }, }); t.addClass("video"); }); //cart and freight $(".additional-add-to-cart").on("click", function () { var e, t, o = $(this).data("variant-id"); -1 < i(o) ? ((t = o), a.splice(i(t), 1), alert("Produto removido!")) : ((e = o), a.push(e), alert("Produto adicionado!")), $(".main_cart_add").data("additional-variant-ids", a); }); $(".coupon-validate").on("keyup", function (e) { $(this).val( $(this) .val() .replace(/[^0-9a-zA-Z_]/g, "") ); }); $("body").on("click", ".btn-cep", function(event){ if (-1 !== window.location.pathname.indexOf("quote")) { var e = $(".flexy-input-postcode").val(), t = [location.protocol, "//", location.host, location.pathname].join("") + "?zipCode=" + e, o = ""; $(".f2-quote-observation").each(function () { var e = $(this).data("observation"), t = $(this).val(); o += "&" + e + "=" + t; }), (window.location = t + o); } }); $("body").on("click", ".additional-to-cart", function(event) { var e = $(this).data("addition-id"); t.add(e), $(".flexy-add-to-cart").one("cart-error", function () { t.delete(e); }); }); $("body").on("click", ".btn-qty button.remove", function(event) { let inputQty = $( this ).parents('.btn-qty').find('.product-quantity'); let qty = parseFloat($(inputQty).val()); if (qty > 1) { $(inputQty).val(qty - 1); } }); $("body").on("click", ".btn-qty button.add", function(event) { let inputQty = $( this ).parents('.btn-qty').find('.product-quantity'); let qty = parseFloat($(inputQty).val()); $(inputQty).val(qty + 1); }); $("body").on("click", ".btn-add-to-cart-qty", function(event) { var $this = $(this); var inputQty = $this.parents('.controls-add-cart').find('.product-quantity'); var qty = parseFloat($(inputQty).val()); var id = $this.data('variant-id'); var additionalIds = $this.data('additional-variant-ids') || []; var dc = $this.data('distributioncenter') || []; var varId = $this.data('variant-id'); $.ajax({ url: '/cart/add', type: 'post', dataType: 'json', data: { id: varId, quantity: qty, additionalVariantId: additionalIds, distributionCenter: dc }, beforeSend: function () { $this.parents('.controls-add-cart').find('.btn-add-to-cart-qty').attr("disabled", !0); }, success: function (data) { $this.parents('.controls-add-cart').find('.btn-add-to-cart-qty').trigger("cart-success", [data.cart]); //location.href = '/cart/'; }, error: function (data) { alert(data.responseJSON.error); $(inputQty).val(qty); } }) .always(function () { $this.parents('.controls-add-cart').find('.btn-add-to-cart-qty').removeAttr("disabled"); }) }); function shippingCalculation() { var postcode = $('.f2-shipping-estimate-postcode').val(); var container = $('.f2-shipping-estimate-container'); var variantId = $('.f2-shipping-estimate-variant-id').val(); if (variantId == undefined) { alert('Informe o produto'); return; } if (postcode == undefined || postcode === "") { alert('Informe o CEP'); return; } $("input[name='distributionCenterReferenceCode']").each(function() { var dcRefCode = $(this).val(); $('#shipping-'+dcRefCode).show(); $.calculate_shipping_by_variant( 'html', function (data) { $('#shipping-'+dcRefCode).html('
Calculando frete...
'); }, function (data) { $('#shipping-'+dcRefCode).html(data); container.html(''); }, postcode, $('.f2-shipping-estimate-quantity').val(), variantId, dcRefCode ); }); } function shippingCalculationOnLoad(){ if(zipCode != "" && calculateBoyBox){ shippingCalculation2(); } else{ exibeSellers(); } } function exibeSellers(){ var countExibe = 0; $(".buy-box-content").each(function() { if(countExibe < 5){ $(this).show(); countExibe++; } }); $('.buy-box-show-more').css('display', 'flex'); } function shippingCalculation2() { var postcode = $('.f2-shipping-estimate-postcode').val(); var container = $('.f2-shipping-estimate-container'); var variantId = $('.f2-shipping-estimate-variant-id').val(); if (variantId == undefined) { alert('Informe o produto'); return; } if (postcode == undefined || postcode === "") { alert('Informe o CEP'); return; } var dcQuantity = $("input[name='distributionCenterReferenceCode']").size(); var cntAux = 0; //$('.buy-box-load').css('display', 'flex'); $("input[name='distributionCenterReferenceCode']").each(function(idx) { var dcRefCode = $(this).val(); $('#shipping-'+dcRefCode).show(); var delay = Math.floor( Math.random() * 500 ) + ( idx * 500 ); setTimeout( function() { $.calculate_shipping_by_variant( 'json', function (data) { $('.buy-best-price-'+dcRefCode).html(''); }, function (data) { var dataReturn = JSON.parse(JSON.stringify(data)); var dataVar = []; for(var i in dataReturn) { dataVar.push(dataReturn[i]); } dataVar.sort(function(a,b) { var priceA = Number.parseFloat(a.price); var priceB = Number.parseFloat(b.price); if(priceA < priceB){ return -1; } if(priceA > priceB){ return 1; } return 0; //return a.price < b.price ? -1 : a.price > b.price ? 1 : 0; }); var infoFrete = ""; for(var i in dataVar) { if(dataVar[i].presentation != undefined && dataVar[i].price != undefined && dataVar[i].deliveryTimeTo != undefined){ var precoAux = dataVar[i].price; if(precoAux == 0){ precoAux = 'Grátis'; } else{ precoAux = 'R$ '+precoAux.toString().replace('.', ','); } infoFrete = infoFrete + '
'+dataVar[i].presentation+': ' +precoAux+' - até ' +dataVar[i].deliveryTimeTo+' dias úteis
'; } } $('.estimate-'+dcRefCode).html(infoFrete); if(dataVar.length <= 0){ $('#buy-box-content-'+dcRefCode).addClass('disabled'); } else{ var minShipping = Number.parseFloat(dataVar[0].price); var minShippingName = dataVar[0].presentation; var timeShipping = dataVar[0].deliveryTimeTo var price = String($('.buy-box-price-'+dcRefCode).html()); price = price.replace('R$ ', '').replace('.','').replace(',','.'); price = Number.parseFloat(price); $('input.product-quantity.buy-box-qty').on('change', () => { let inputFirstValue = parseFloat($('input.product-quantity.buy-box-qty').val()) let newTotal = (((price * inputFirstValue) + minShipping).toFixed(2).toString()) let inputNewValue = ((price * inputFirstValue).toFixed(2).toString()) let formatInputNewValue = (inputNewValue.toLocaleString('pt-BR', {style: 'currency',currency: 'BRL',})).replace('.', ',') $('.buy-box-price-'+dcRefCode).html(`R$ ${formatInputNewValue}`) let formatNewTotal = (newTotal.toLocaleString('pt-BR', {style: 'currency',currency: 'BRL',})).replace('.', ','); $('.buy-best-price-'+dcRefCode).html(`R$ ${formatNewTotal}`); }) var total = price + minShipping; var totalCurrency = total.toLocaleString('pt-BR', {style: 'currency',currency: 'BRL',}); $('.buy-best-price-'+dcRefCode).html(totalCurrency); $('.buy-box-price-'+dcRefCode).addClass('unit-price'); $('.label-price-shipping').show(); $('#buy-box-content-'+dcRefCode).attr('data-best-value', total); } cntAux++; if(cntAux === dcQuantity){ orderBuyBox(0); exibeSellers(); //shippingCalculation(); } }, postcode, $('.f2-shipping-estimate-quantity').val(), variantId, dcRefCode )} , delay ); }); } var actualOrientation = 0; $("body").on("click", ".best-price-order", function(event) { if(actualOrientation === 0){ orderBuyBox(1); } else { orderBuyBox(0); } }); function orderBuyBox(orientation){ var $wrapper = $('.buy-box-block'); $wrapper.find('.buy-box-content').sort(function (a, b) { if ($(a).hasClass('disabled')){ return 1; } else if ($(b).hasClass('disabled')){ return -1; } else if (orientation === 0) { return +a.dataset.bestValue - +b.dataset.bestValue; } else if (orientation === 1){ return +b.dataset.bestValue - +a.dataset.bestValue; } else{ alert('Erro ao ordenar buybox'); } }) .appendTo( $wrapper ); actualOrientation = orientation; if (orientation === 1){ $('.best-price-order i.fa-arrow-circle-o-down').hide(); $('.best-price-order i.fa-arrow-circle-o-up').show(); } else{ $('.best-price-order i.fa-arrow-circle-o-up').hide(); $('.best-price-order i.fa-arrow-circle-o-down').show(); } } $('.buy-box-show-more').on('click', function (e) { e.preventDefault(); $(".buy-box-content").show(); $(this).hide(); }); $('#zipCode').keyup(function(e){ if(e.keyCode == 13) { if(zipCode != ""){ zipCode = $('.f2-shipping-estimate-postcode').val(); grava_cookie('zipCode', zipCode); shippingCalculation2(); } else{ zipCode = $('.f2-shipping-estimate-postcode').val(); grava_cookie('zipCode', zipCode); window.location.reload(); } } }); $('.f2-shipping-estimate-quantity').on('input',function(e){ var inputQuantity = $(this).val(); $(".buy-box-content").each(function() { var quantity = $(this).data('maxQuantity'); if (quantity < inputQuantity){ $(this).addClass('disabled'); } else{ $(this).removeClass('disabled'); } }); }); $('.f2-multiple-dc-shipping-estimate-action-2').on('click', function (e) { e.preventDefault(); if(zipCode != ""){ zipCode = $('.f2-shipping-estimate-postcode').val(); grava_cookie('zipCode', zipCode); shippingCalculation2(); } else{ zipCode = $('.f2-shipping-estimate-postcode').val(); grava_cookie('zipCode', zipCode); window.location.reload(); } }); function cookie_produto(){ var cook = get_cookie('cookie_prod_info'); if (cook != "accept"){ $("#dialog").fancybox({ 'afterClose' : function() { grava_cookie('cookie_prod_info', 'accept'); } }).trigger('click'); } } function grava_cookie(key, value){ Cookies.set(key, value, { expires: 365 }); } function get_cookie(key){ return Cookies.get(key); } $(document).on('click', '.flexy-accept-cookie', function(){ grava_cookie('agree_cookies', 'accept'); grava_cookie('prm_dtd', new Date()); $('.lgpd').hide(); }); function cookie_agree(){ var cook = get_cookie('agree_cookies'); $('.cookie_test').html(cook); if (cook != "accept"){ $('.lgpd').show(); } } $(document).ready(function (){ cookie_agree(); }); $(".customer-create").on('submit', function(e){ if(!acceptLGPD){ e.preventDefault(); e.stopImmediatePropagation(); $('.block-lgpd').fancybox().trigger('click'); } }); $('.agree-lgpd').on('click', function(){ acceptLGPD = true; $(this).prop("disabled",true); $(this).html(''); $(".customer-create").submit(); }); function loadLgpdContent(){ $.ajax({url: "/aceite-lgpd", success: function(result){ $(".content-lgpd").html(result); }}); } $(document).ready(function (){ let url = window.location.href.split('/'); if (url.length > 4) { console.log(url[3] + url[4]) if (url[3] + url[4] === "produtolistar") { let logo = $('.header-logo') logo.html('Loja Virtual Suryha') } else { if (url[3] === "produto" && url[4] != "listar") { let logo = $('.header-logo') logo.html('Loja Virtual Suryha') } } } return null; })