Learn the details about how to set a minimum/maximum order amount in WooCommerce.
Use below snippet code to display the sale price before the regular price. Add this code in active theme function.php.
Minimum
add_action( 'woocommerce_check_cart_items', 'required_cart_subtotal_amount' );
function required_cart_subtotal_amount() {
$minimum_amount = 100;
$cart_subtotal = WC()->cart->subtotal;
if( $cart_subtotal < $minimum_amount ) {
wc_add_notice( '<strong>' . sprintf( __("A minimum total purchase amount of %s is required to checkout."), wc_price($minimum_amount) ) . '<strong>', 'error' );
}
}
Maximum
add_action( 'woocommerce_check_cart_items', 'required_cart_subtotal_amount' );
function required_cart_subtotal_amount() {
$minimum_amount = 100;
$cart_subtotal = WC()->cart->subtotal;
if( $cart_subtotal > $minimum_amount ) {
wc_add_notice( '<strong>' . sprintf( __("A maximum total purchase amount of %s is required to checkout."), wc_price($minimum_amount) ) . '<strong>', 'error' );
}
}
Total Views: 1,347