Title: 2.1.3 Minimum Order Required
Last modified: August 21, 2016

---

# 2.1.3 Minimum Order Required

 *  [dcbaldwin1](https://wordpress.org/support/users/cousti/)
 * (@cousti)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/213-minimum-order-required/)
 * WordPress 3.8.1 with WooCommerce 2.1.3 on Media Temple gs…
 * Does anyone know of a tested method to require a minimum order amount for 2.1.3?
   I am currently using the code snippet below. It does prevent you from accessing
   the checkout page if your order does not meet the minimum, however, if you do
   meet the minimum and successfully checkout, you are still redirected back to 
   the cart, which is now empty because the order went through. Before the redirect
   back to the cart, the site does attempt to load the order-recieved page (endpoint),
   but the redirect happens before the page loads that has the order confirmation,
   making the purchaser think their order did not go through when it did.
 *     ```
       add_action('the_post','minimum_order_func',10);
       function minimum_order_func(){
       global $woocommerce;
       if ( is_checkout() ) {
       	$minorder = 150;
       	if( $woocommerce->cart->subtotal < $minorder){
       		 $woocommerce->add_error( sprintf(__('Sorry, you have not met the minimum order amount of $' . $minorder . '. Once you do meet this minimum, you can proceed with the checkout. <a href="%s/store">Continue Shopping &rarr;</a>', 'woocommerce'), home_url()) );
       		    wp_redirect( get_permalink( woocommerce_get_page_id( 'cart' ) ) );
       		   			exit;
       		}
       	}
       }
       ```
   
 * [https://wordpress.org/plugins/woocommerce/](https://wordpress.org/plugins/woocommerce/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Thread Starter [dcbaldwin1](https://wordpress.org/support/users/cousti/)
 * (@cousti)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/213-minimum-order-required/#post-4673746)
 * Okay I tried this (hacky) work-around which does prevent the redirect after successful
   checkout, but, the error message still shows on the order-received page.
 *     ```
       add_action('the_post','minimum_order_func',10);
       function minimum_order_func(){
       global $woocommerce;
       if ( is_checkout() ) {
   
       	$minorder = 150;
   
       	$url = 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
   
       	if( $woocommerce->cart->subtotal < $minorder ){
   
       		 $woocommerce->add_error( sprintf(__('Sorry, you have not met the minimum order amount of $' . $minorder . '. Once you do meet this minimum, you can proceed with the checkout. <a href="%s/store">Continue Shopping &rarr;</a>', 'woocommerce'), home_url()) );
   
       		 	if (false !== strpos($url,'order-received')) { //order recieved enpoint exists
       			    //do nothing
       			} else {
       		    wp_redirect( get_permalink( woocommerce_get_page_id( 'cart' ) ) );
       		   			exit;
       		   	}
   
       		}
       	}
       }
       ```
   
 *  [Roy Ho](https://wordpress.org/support/users/splashingpixelscom/)
 * (@splashingpixelscom)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/213-minimum-order-required/#post-4673750)
 * See if this helps [http://docs.woothemes.com/document/minimum-order-amount/](http://docs.woothemes.com/document/minimum-order-amount/)
 *  Thread Starter [dcbaldwin1](https://wordpress.org/support/users/cousti/)
 * (@cousti)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/213-minimum-order-required/#post-4673756)
 * Thanks Roy. The snippet provided at [http://docs.woothemes.com/document/minimum-order-amount/](http://docs.woothemes.com/document/minimum-order-amount/)
   doesn’t seem to do anything at all.
 *  Thread Starter [dcbaldwin1](https://wordpress.org/support/users/cousti/)
 * (@cousti)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/213-minimum-order-required/#post-4673762)
 * Okay I have accomplished what I want, but I still feel it’s ‘hacky.’ Below is
   my code. I moved the output of the error into the else block:
 *     ```
       add_action('the_post','minimum_order_func',10);
       function minimum_order_func(){
       	global $woocommerce;
   
       	if ( is_checkout() ) {
   
       		$minorder = 150;
   
       		$url = 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
   
       		if( $woocommerce->cart->subtotal < $minorder ){
   
       		 	if (false !== strpos($url,'order-received')) { //order recieved enpoint exists
       			    //do nothing
       			} else {
   
       			 $woocommerce->add_error( sprintf(__('Sorry, you have not met the minimum order amount of $' . $minorder . '. Once you do meet this minimum, you can proceed with the checkout. <a href="%s/store">Continue Shopping →</a>', 'woocommerce'), home_url()) );
   
       		     wp_redirect( get_permalink( woocommerce_get_page_id( 'cart' ) ) );
   
       		   	 exit;
       		   	}
   
       		}
       	}
       }
       ```
   
 *  [vark](https://wordpress.org/support/users/vark/)
 * (@vark)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/213-minimum-order-required/#post-4673781)
 * This might put your feet on the path:
    [http://wordpress.org/plugins/minimum-purchase-for-woocommerce/](http://wordpress.org/plugins/minimum-purchase-for-woocommerce/)

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘2.1.3 Minimum Order Required’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

## Tags

 * [minimum order](https://wordpress.org/support/topic-tag/minimum-order/)

 * 5 replies
 * 3 participants
 * Last reply from: [vark](https://wordpress.org/support/users/vark/)
 * Last activity: [12 years, 2 months ago](https://wordpress.org/support/topic/213-minimum-order-required/#post-4673781)
 * Status: not resolved