rafaelcmgt
8/9/2018 - 10:50 AM

Autoactualizar carrito al cambiar cantidades

CSS

button[name='update_cart'] {
    display: none !important;
}

Functions.php

/*
* Woocommerce: autoactualizar carrito al cambiar cantidades
*/
add_action( 'woocommerce_after_cart', function() {
  ?>
      <script>
          jQuery(function($) {
              var timeout;
              $('div.woocommerce').on('change textInput input', 'form.woocommerce-cart-form input.qty', function(){
                  if(typeof timeout !== undefined) clearTimeout(timeout);

                  //No actualizar si se deja el campo vacío
                  if ($(this).val() == '') return;

                  timeout = setTimeout(function() {
                      $("[name='update_cart']").trigger("click"); 
                  }, 1500);
              }); 
          });
      </script>
  <?php
} );