Maximum Order Amount
Blocks checkout when the cart subtotal goes over a set amount and shows a notice asking the shopper to contact you for large orders.
Opens WPIDE on
Code
add_action( 'woocommerce_check_cart_items', function () {
$maximum = 1000; // Highest subtotal allowed per order.
$subtotal = (float) WC()->cart->get_subtotal();
if ( $subtotal > $maximum ) {
wc_add_notice( sprintf( 'Orders above %s cannot be placed online. Please contact us for a quote.', wc_price( $maximum ) ), 'error' );
}
} );
Notes
Change $maximum. The check uses the cart subtotal before shipping.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.