icon_check Envío gratuito

icon_check Envío rápido en 1-3 días

icon_check Garantía de devolución del dinero en 30 días

icon_check Envío gratuito icon_check Envío rápido en 1-3 días icon_check Garantía de devolución del dinero en 30 días

Tu carrito esta vacío

Volver a la tienda

jQuery(function($) { function updateFormFieldVisibility() { // Make AJAX request to get cart items $.ajax({ type: 'POST', url: "/wp-admin/admin-ajax.php", data: { action: 'get_cart_items', }, success: function(response) { console.log(response['cart_items']); // Check if the specific product is in the cart and the quantity is greater than 4 var isProductInCart = false; var isMoreThen4 = false; var inCart = false; $.each(response['cart_items'], function(key, cartItem) { if (cartItem.product_id == 8987) { inCart = true; } }); if (response['cart_count'] > 4) { isMoreThen4 = true; } if (isMoreThen4) { $('.optional').remove(); $('#b2b_customer').show(); } else { $('#b2b_customer').hide(); if (inCart) { removeFromCartByProductId(8987); } } }, }); } $(document.body).on('updated_cart_totals', function() { updateFormFieldVisibility(); }); updateFormFieldVisibility(); $('body').on('change', '#is_b2b_customer', function() { if ($(this).is(':checked')) { addToCartByProductId(8987); } if (!$(this).is(':checked')) { removeFromCartByProductId(8987); } }); function addToCartByProductId(productId, quantity) { $.ajax({ type: 'POST', url: "/wp-admin/admin-ajax.php", data: { action: 'add_to_cart', product_id: productId, }, success: function(response) { jQuery("[name='update_cart']").removeAttr('disabled'); jQuery("[name='update_cart']").trigger("click"); setTimeout(function() { var productId = '8987'; var cartItems = document.querySelectorAll( '.woocommerce-cart-form__cart-item'); cartItems.forEach(function(cartItem) { var removeLink = cartItem.querySelector( '.product-remove a'); if (removeLink && removeLink.getAttribute( 'data-product_id') === productId) { var quantityInput = cartItem.querySelector( '.ux-quantity.quantity.buttons_added.form-minimal' ); if (quantityInput) { quantityInput.style.display = 'none'; } } }); }, 1000); }, }); } function removeFromCartByProductId(productId) { $.ajax({ type: 'POST', url: "/wp-admin/admin-ajax.php", data: { action: 'remove_from_cart', product_id: productId, }, success: function(response) { jQuery("[name='update_cart']").removeAttr('disabled'); jQuery("[name='update_cart']").trigger("click"); }, }); } });