0

We are using woocommerce and We need to make the order total price to be limited more than 15 KD.

If a customer added items to the cart and the total price less than 15 he can't proceed to checkout.

1

Put this code in your current theme function.php file.

METHOD 1:

add_action( 'woocommerce_check_cart_items', 'spyr_set_weight_requirements' );
function spyr_set_weight_requirements() {
    if( is_cart() || is_checkout() ) {
        global $woocommerce;
        $total = WC()->cart->total;
        if( $total < 15 ){
        wc_add_notice( '<strong>MAXIMUM CART PRICE 15 FOR CHECKOUT</strong>','error');
        }
    }
}

METHOD:2

function disable_checkout_button_no_shipping() {
    $total = WC()->cart->total;

    if( $total < 15 ){
        remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 );
        echo '<a href="#" class="checkout-button button alt wc-forward">Proceed to checkout</a>';

    }  
}
add_action( 'woocommerce_proceed_to_checkout', 'disable_checkout_button_no_shipping', 1 );

In First method page redirect checkout but display only message.

METHOD 3:

function disable_checkout_button_no_shipping() {
    $total = WC()->cart->total;

    if( $total < 15 ){
        remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 );

    }  
}
add_action( 'woocommerce_proceed_to_checkout', 'disable_checkout_button_no_shipping', 99 );  
  • I need to remove the proceed to checkout if less than 15 – Mohamed Badawy Jan 5 '18 at 17:07
  • Yes then you can use second method for this. Put this function your function.php file. – Jignesh Patel Jan 5 '18 at 17:17
  • Thanks for your reply but it doesn't work Can you please check this is for our cart with order 4 and checkout button still not removed i.imgur.com/cdBTYHK.png – Mohamed Badawy Jan 7 '18 at 6:58
  • kindly check it – Mohamed Badawy Jan 7 '18 at 7:22
  • check my updated answer. – Jignesh Patel Jan 8 '18 at 3:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.