Set a minimum undiscounted order amount in WooCommerce
Updated: Use the following revisited and compacted code, that uses the undiscounted total:
add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' );add_action( 'woocommerce_before_cart' , 'wc_minimum_order_amount' );function wc_minimum_order_amount() { // Set this variable to specify a minimum order value $minimum = 50; $total = WC()->cart->total; $discount_total = WC()->cart->get_discount_total(); // updated thanks to 7uc1f3r $maximized_total = $total + $discount_total; if ( $maximized_total < $minimum ) { $notice = sprintf( __('Your current order total is %s — you must have an order with a minimum of %s to place your order '), wc_price( $maximized_total ), wc_price( $minimum ) ); if( is_cart() ) { wc_print_notice( $notice , 'error' ); } else { wc_add_notice( $notice , 'error' ); } }}
Code goes in functions.php file of your active child theme (or active theme). Tested and works.