I added a custom function to validate the cart to check if a minimum order is reached, if not a notice is displayed and the checkout button is disabled.
When i increment the number of products to reach the minimum, the update cart button is enabled and the total is updated with AJAX, but the notice is still there and the checkout button is still disabled.

I’m pretty sure the ajax function was added by the theme’s developers, i didn’t touch it at all.

This is some pseudo-code i’m using in my functions.php:

function my_checkout_button_disabled() {
    ?><a class="checkout-button button disabled alt wc-forward">Checkout disabled</a><?php
}

add_action('woocommerce_check_cart_items', 'my_items_check');
function my_items_check() {
    if(/* items_are_wrong or minimum not reached */) {
        // add error notice and disable checkout
        wc_add_notice("There's something wrong", 'error');
        remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 ); 
        add_action('woocommerce_proceed_to_checkout', 'my_checkout_button_disabled', 11);
    } else {
        return true;
    }
}
add_action('woocommerce_add_to_cart_validation', 'my_a2c_validation');
function my_a2c_validation() {
    if(/* item not compatible with cart */) {
        // add error notice
        wc_add_notice("There's something wrong", 'error');
    } else {
        return true;
    }
}

I need these validations to be executed also after the ajax update to eventually remove the notice and activate the checkout.
How to achieve this?

Read more here: WooCommerce re-validate cart after update cart ajax


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: