Created
December 8, 2022 15:49
-
-
Save xplodedthemes/3b897d696b25c0fd1365b541c915995d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function prefix_wc_minimum_order_amount() { | |
// Set this variable to specify a minimum order value | |
$minimum = 100; | |
if ( WC()->cart->total < $minimum ) { | |
$message = sprintf( 'You must have an order with a minimum of %s to place your order, your current order total is %s.' , | |
wc_price( $minimum ), | |
wc_price( WC()->cart->total ) | |
); | |
wc_add_notice( $message, 'error'); | |
} | |
} | |
add_action( 'woocommerce_check_cart_items', 'prefix_wc_minimum_order_amount' ); | |
add_action( 'woocommerce_checkout_process', 'prefix_wc_minimum_order_amount' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment