?php
function set_minimum_order_amount() {
$minimum_amount = 300; // Replace this with your desired minimum order amount
if ( WC()->cart->subtotal < $minimum_amount ) { if( is_cart() ) { wc_print_notice( sprintf( 'Your current order total is %s — you must have an order with a minimum of %s to place your order.' , wc_price( WC()->cart->subtotal ),
wc_price( $minimum_amount )
), 'error'
);
} else {
wc_add_notice(
sprintf( 'Your current order total is %s — you must have an order with a minimum of %s to place your order.' ,
wc_price( WC()->cart->subtotal ),
wc_price( $minimum_amount )
), 'error'
);
}
}
}
add_action( 'woocommerce_check_cart_items', 'set_minimum_order_amount' );
?>