Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xplodedthemes/3b897d696b25c0fd1365b541c915995d to your computer and use it in GitHub Desktop.
Save xplodedthemes/3b897d696b25c0fd1365b541c915995d to your computer and use it in GitHub Desktop.
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