After testing the cart page for the product with the changeable quantity, here are my findings:
1. Plugin CSS and JS isn’t loaded.
2. The default setting to change the minimum quantity in the cart from 0 to 1 may or may not work. You could test it by changing it in plugin settings. The minimum is 1, but it can be 1 either from Ajax Cart AutoUpdate or WooCommerce not applying this default minimum because of custom changes.
3. The default WooCommerce Ajax event on pressing the “Update cart” button doesn’t work. The page is fully reloaded. My plugin is based on this event and won’t work without it.
This is how the style to hide the button is added (cart page only):
add_action( 'wp_head', 'acau_hide_update_cart_button', 20 );
This is how the script is added, using a WooCommerce helper function wc_enqueue_js
which is probably disabled on your website (cart page only):
add_action( 'template_redirect', function() use ( $args ) { ajax_cart_autoupdate( $args ); });
function acau_enqueue_script( $args ) {
wc_enqueue_js( '
var timeout;
jQuery("div.woocommerce").on("change keyup mouseup", "input.qty, select.qty", function(){ // keyup and mouseup for Firefox support
if (timeout != undefined) clearTimeout(timeout); //cancel previously scheduled event
if (jQuery(this).val() == "") return; //qty empty, instead of removing item from cart, do nothing
timeout = setTimeout(function() {
jQuery("[name=\"update_cart\"]").trigger("click");
}, ' . $args["update_delay"] . ' ); // schedule update cart event with delay in miliseconds specified in plugin settings
});
' );
}
$args["update_delay"]
is the numeric value set in plugin settings.
Due to how the plugin is connected to WooCommerce functionality, it will be extremely difficult to make it work without WooCommerce in its default state.
-
This reply was modified 5 years, 2 months ago by taisho.