");
}
$(".shop-container #product-load-curtain").hide();
});
// -----------------Cart-------------------
$(document).ready(function () {
$(document).ajaxStop(function () {
updateCartCupon();
updateCheckoutLoadingBar();
// $("#cart-load-curtain").hide();
});
});
function updateCartCupon() {
$(".cart-container .cart-subtotal").after("
|
");
$(".cart-container .checkout_coupon").clone().addClass("form-coupon-visible").appendTo(".cart-container #checkout-coupon");
$(".cart-container .coupon .wp-element-button").removeClass("is-form");
$(".cart-container .woocommerce-form-coupon-toggle").remove();
$(".cart-container .widget-title").remove();
}
function updateCheckoutLoadingBar() {
$(".cart-container .woocommerce-shipping-totals").before("
|
");
$("#checkout-loading-bar").append($(".cart-container .devnet_fsl-free-shipping"));
}
//------------------Minicart---------------
$(document).ready(function () {
$(document).on("click", ".cart-item", function () {
renderMiniCart();
});
$(document.body).on("wc_fragments_refreshed", function () {
renderMiniCart();
});
$(document).on("click", ".cart-custom-quantity-add", function () {
$("#minicart-load-curtain").css("display", "flex");
var productId = $(this).attr("data-product_id");
$.ajax({
url: hc_custom_template_vars.ajaxurl,
type: "POST",
data: {
action: "add_to_mini_cart",
product_id: productId,
},
success: function (response) {
$(".widget_shopping_cart_content").html(response["fragments"]);
renderMiniCart();
},
});
});
$(document).on("click", ".cart-custom-quantity-remove", function () {
$("#minicart-load-curtain").css("display", "flex");
var cartItemKey = $(this).attr("data-cart_item_key");
$.ajax({
url: hc_custom_template_vars.ajaxurl,
type: "POST",
data: {
action: "remove_from_mini_cart",
cart_item_key: cartItemKey,
},
success: function (response) {
$(".widget_shopping_cart_content").html(response["fragments"]);
renderMiniCart();
},
});
});
$(document).on("click", ".remove-mini-cart-item", function (e) {
e.stopPropagation();
$("#minicart-load-curtain").css("display", "flex");
var cartItemKey = $(this).attr("data-cart_item_key");
$.ajax({
url: hc_custom_template_vars.ajaxurl,
type: "POST",
data: {
action: "remove_from_mini_cart_complete",
cart_item_key: cartItemKey,
},
success: function (response) {
$(".widget_shopping_cart_content").html(response["fragments"]);
renderMiniCart();
},
});
});
});
function renderMiniCart() {
$("#cart-popup .woocommerce-mini-cart").append("
");
$("#cart-popup .woocommerce-mini-cart-item").each(function () {
var parent = $(this);
var productId = $(this).find(".remove_from_cart_button").attr("data-product_id");
var cartItemKey = $(this).find(".remove_from_cart_button").attr("data-cart_item_key");
$(this)
.find(".remove_from_cart_button")
.replaceWith("
×");
$(this).find(".quantity").hide();
var qtyText = $(this).find(".quantity").text();
var trimIndex = qtyText.indexOf("×");
var qty = qtyText.substring(0, trimIndex).trim();
var price = qtyText.substring(trimIndex + 1).trim();
if (!$(this).find(".cart-custom-quantity-container").length) {
$(this).find(".quantity").before("
");
$(this)
.find(".cart-custom-quantity-wrap")
.append("
" + price + "
");
$(this)
.find(".cart-custom-quantity-wrap")
.append("
");
}
$("#products_brand_data > input").each(function () {
var productBrandId = $(this).attr("data-product-id");
if (parseInt(productBrandId) === parseInt(productId)) {
if ($(this).val() !== "SIN MARCA") {
parent.find(".remove-mini-cart-item").before(`
${$(this).val()}
`);
}
return false;
}
});
});
$("#cart-popup .woocommerce-mini-cart__total").before($("#cart-popup .devnet_fsl-free-shipping"));
$("#minicart-load-curtain").hide();
}
// -----------------Store------------------
$(document).ready(function () {
updateStoreMenuOption();
});
function updateStoreMenuOption() {
$(".shop-page-title").prepend("");
$(".shop-page-title .is-medium").clone().addClass("screen-small").appendTo(".shop-page-title #store-menu-options");
$(".shop-page-title .filter-button").html("

Filtrar

");
// $("#shop-load-curtain").hide();
}
// -----------------Shared------------------
var firstLoadSearchBar = true;
$(document).ready(function () {
/*$(document).on("DOMNodeInserted", ".products", function () {
addBrandToProduct();
});*/
$(".dgwt-wcas-search-wrapp").click(function () {
if (firstLoadSearchBar) {
addIconToSearchBar();
firstLoadSearchBar = false;
}
setSearchPosition();
});
$(document).on("click", ".hc-custom-template-menu-item-parent, .hc-custom-template-menu-item-child", function () {
var groupId = $(this).attr("data-menu-id");
var url = $(this).attr("data-menu-url");
var text = $(this).find(".hc-custom-template-menu-item-text").text();
setCurrentMenu(parseInt(groupId), text, url);
});
$(document).on("click", "#hc-custom-template-back", function () {
$(this).css("visibility", "hidden");
setCurrentMenu(0, "Tienda", "");
});
$(document).on("click", "#hc-custom-template-close", function () {
$("#hc-custom-template-viewer-container").css("display", "none");
$("html").css("overflow", "auto");
setCurrentMenu(0, "Tienda", "");
});
$(document).on("click", "#hc-custom-template-open", function () {
var parent = $(this).parent();
$("#hc-custom-template-viewer-container").css("display", "flex");
$("html").css("overflow", "hidden");
parent.siblings().removeClass("current_page_item");
parent.addClass("current_page_item");
});
$(document).on("click", ".dgwt-wcas-om-return", function () {
$(".mobile-nav .icon-menu").show();
});
$(document).on("scroll", function () {
setSearchPosition();
});
$(".mobile-nav .dgwt-wcas-search-icon").append("
Buscar");
setCommunity();
/*addBrandToProduct();*/
replaceStoreMenu();
setCurrentMenu(0, "Tienda", "");
});
function addIconToSearchBar() {
$("#dgwt-wcas-search-input-3").after("

");
}
function setSearchPosition() {
var topBarHeight = $(".header-wrapper").outerHeight();
$(".js-dgwt-wcas-overlay-mobile").css("transform", `translateY(${topBarHeight}px)`);
}
function setCommunity() {
var userName = $("#user_name").val();
var userAvatar = $("#user_avatar").val();
if (userName !== undefined) {
$("#menu-item-437097 .row:first-child .col-inner > .icon-box:first-child h4 strong").text(userName);
$("#menu-item-437097 .row:first-child .col-inner > .icon-box:first-child img").attr("src", userAvatar).attr("srcset", userAvatar).attr("data-srcset", userAvatar).attr("data-src", userAvatar);
} else {
$("#menu-item-437097 .row:first-child .col-inner > .icon-box:first-child h4").hide();
$("#menu-item-437097 .row:first-child .col-inner > .icon-box:first-child .icon-box-img").hide();
}
}
function addBrandToProduct() {
$(".product-small").each(function () {
if (!$(this).find(".hc_custom_template_brand").length) {
var parent = $(this).find(".review-widget");
var productId = $(this).find("ryviu-widget-total").attr("product_id");
$("#products_brand_data > input").each(function () {
var productBrandId = $(this).attr("data-product-id");
if (parseInt(productBrandId) === parseInt(productId)) {
if ($(this).val() !== "SIN MARCA") {
parent.after(`
${$(this).val()}
`);
}
return false;
}
});
}
});
}
function setCurrentMenu(currentGroupId, title, url) {
var hasChilds = false;
$("#hc-custom-template-text").text(title);
$("#hc-custom-template-menu .hc-custom-template-menu-group").each(function () {
var groupId = $(this).attr("data-menu-id");
if (parseInt(groupId) === currentGroupId) {
var clone = $(this).clone();
$("#hc-custom-template-viewer").html(clone);
if (currentGroupId !== 0) {
$("#hc-custom-template-back").css("visibility", "visible");
} else {
$("#hc-custom-template-back").css("visibility", "hidden");
}
hasChilds = true;
}
});
if (!hasChilds) {
window.location.href = url;
}
}
function replaceStoreMenu() {
var content = $(".bnav_main_menu #menu-item-437312").html();
var newContent = content.replace('