A simple, powerful and independent e-commerce platform.
Sell anything with ease.

Set a minimum order amount for checkout

This code sets a minimum amount that will allow you to proceed with a checkout. The example uses 50 as the minimum and the checkout button is disabled until that amount is reached.

		/**
 * Set a minimum order amount for checkout
 */

add_action('woocommerce_checkout_process', 'cc_minimum_order_amount');
add_action('woocommerce_before_cart', 'cc_minimum_order_amount');

function cc_minimum_order_amount() {

  // Set this variable to specify a minimum order value
  $minimum = 50;

  if (WC()->cart->total < $minimum) {

    if(is_cart()) {

      remove_action( 'woocommerce_proceed_to_checkout','woocommerce_button_proceed_to_checkout', 20);
      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->total), 
          wc_price( $minimum)
        ), 'error' 
      );

    } else {

      remove_action( 'woocommerce_proceed_to_checkout','woocommerce_button_proceed_to_checkout', 20);
      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->total), 
         wc_price($minimum)
        ), 'error' 
      );

    }
  }
}
	
View Raw Code ID: 91087