Hi @kevrex
Please try adding the code below – I would recommend using a plugin like Code Snippets to add the snippet to your site.
/**
* Set a maximum order amount for checkout
*/
add_action( 'woocommerce_checkout_process', 'wc_maximum_order_amount' );
add_action( 'woocommerce_before_cart' , 'wc_maximum_order_amount' );
function wc_maximum_order_amount() {
// Set this variable to specify a maximum order value
$maximum = 10;
if ( WC()->cart->total > $maximum ) {
if( is_cart() ) {
wc_print_notice(
sprintf( 'Your current order total is %s — you must have an order with a maximum of %s to place your order ' ,
wc_price( WC()->cart->total ),
wc_price( $maximum )
), 'error'
);
} else {
wc_add_notice(
sprintf( 'Your current order total is %s — you must have an order with a maximum of %s to place your order' ,
wc_price( WC()->cart->total ),
wc_price( $maximum )
), 'error'
);
}
}
}