Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Place in your theme’s functions.php file or custom plugin. Will only allow customers to checkout is their cart total is greater than 50.
add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' );
function wc_minimum_order_amount() {
global $woocommerce;
$minimum = 10;
if ( $woocommerce->cart->get_cart_total() < $minimum ) {
$woocommerce->add_error( sprintf( 'You must have an order with a minimum of %s to place your order.' , $minimum ) );
}
}
@sandovalg

This comment has been minimized.

Copy link

@sandovalg sandovalg commented Dec 1, 2013

I am receiving an error on line 6 of your code unexpected syntax ";" for the 6 line. Any thoughts? In this particular gist the minimum is set to 10 correct?

@raramuridesign

This comment has been minimized.

Copy link

@raramuridesign raramuridesign commented Jan 16, 2014

Line 6
should look like this

if ( $woocommerce->cart->get_cart_total() < $minimum ) {

The semi-colon should be removed.

@BFTrick

This comment has been minimized.

Copy link

@BFTrick BFTrick commented Feb 25, 2014

@raramuridesign - Yup. I just went in and fixed this. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.