Buy B2BKing
$199 $149
If you are using Dynamic Rules such as "Minimum Order" and would like to prevent the user from clicking "Proceed to Checkout" when there are errors in the cart, you can add the following JavaScript snippet to your website. It will make the button non-functional when clicked.
add_action('wp_head', function(){ ?> <script> jQuery(document).ready(function(){ jQuery('body.woocommerce-cart').on('click', '.wc-proceed-to-checkout', function(e){ if (jQuery('.woocommerce-error').length > 0) { e.preventDefault(); } }); }); </script> <?php });
Depending on theme, you may have to change ".woocommerce-error" to ".woocommerce-info"
If you want to completely hide/show the button based on cart errors, you can add the following snippet to your website:
add_action('wp_head', function(){ ?> <script> jQuery(document).ready(function(){ jQuery( document.body ).on( 'updated_cart_totals', function(){ if (jQuery('.woocommerce-error').length > 0) { jQuery('.wc-proceed-to-checkout').css('display','none'); } else { jQuery('.wc-proceed-to-checkout').css('display','block'); } }); }); </script> <?php });
Powered by BetterDocs