Remove process to checkout button based on minimum cart total in WooCommerce

Remove process to checkout button based on minimum cart total in WooCommerce on child sites.

Snippet Type

Execute on Child Sites

Snippet

function action_woocommerce_check_cart_items() {
    // Setting
    $minimum = 500;

    // Get cart total
    $cart_total = WC()->cart->get_cart_contents_total();

    // Less than the minimum
    if ( $cart_total < $minimum ) {
        // Notice
        wc_add_notice( sprintf( __( 'Wholesale Orders is only valid on order more than %s Euros.', 'woocommerce' ), $minimum ), 'error' );
        
        // Optional: remove proceed to checkout button
        remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 );
    }
}   
add_action( 'woocommerce_check_cart_items' , 'action_woocommerce_check_cart_items', 10 );

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.