Title: Minimum order amount
Last modified: July 30, 2020

---

# Minimum order amount

 *  Resolved [stefanig](https://wordpress.org/support/users/stefanig/)
 * (@stefanig)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/minimum-order-amount-5/)
 * Hello,
    I use a minimum order code that works well, but I want to use this code
   according to the states that I have on my website. I want state 1 to have a minimum
   of 30$ and state 2 to be 45$ I’m sending you a link to my code: [https://pastebin.com/tQk0FcfB](https://pastebin.com/tQk0FcfB)
   The problem is that even if I don’t update my cart, it allows me to continue 
   to checkout, also allows me to complete my order in checkout and I shouldn’t 
   do it.

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

 *  [Rynald0s](https://wordpress.org/support/users/rynald0s/)
 * (@rynald0s)
 * Automattic Happiness Engineer
 * [5 years, 9 months ago](https://wordpress.org/support/topic/minimum-order-amount-5/#post-13196155)
 * Hi
 * You are currently using:
 *     ```
       $state = array('BG-23');  
   
                $cart_total_order = WC()->cart->total;
   
       		 if( $cart_total_order < $minimum && in_array(WC()->customer->get_shipping_state(), $state )  ) {
       ```
   
 * You’ll want to use something like this:
 *     ```
       $state = $woocommerce->customer->get_shipping_state();
   
               if( $cart_total_order < $minimum  && $state == 'BG-23'  ) {
       ```
   
 * Let me know if that helps.
 * Cheers!
    -  This reply was modified 5 years, 9 months ago by [Rynald0s](https://wordpress.org/support/users/rynald0s/).
 *  Thread Starter [stefanig](https://wordpress.org/support/users/stefanig/)
 * (@stefanig)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/minimum-order-amount-5/#post-13202292)
 * Hello,
    Thank you for your replay. I’m sorry, but it doesn’t work, it still allows
   me to complete my order even if the amount is below the minimum… I’ve tried this
   function for disabling proceed to checkout button, but I have an error and I 
   don’t know where to insert it to work well.
 * **function disable_checkout_button_no_shipping() {
    remove_action( ‘woocommerce_proceed_to_checkout’,‘
   woocommerce_button_proceed_to_checkout’, 20 ); echo ‘[Proceed to checkout](https://wordpress.org/support/topic/minimum-order-amount-5/?output_format=md#)‘;}
   add_action( ‘woocommerce_proceed_to_checkout’, ‘disable_checkout_button_no_shipping’,
   1 );
 * Can you edit it for me and tell me where to insert it?
 * Best wishes,
    Stefani
    -  This reply was modified 5 years, 9 months ago by [stefanig](https://wordpress.org/support/users/stefanig/).
    -  This reply was modified 5 years, 9 months ago by [stefanig](https://wordpress.org/support/users/stefanig/).
 *  [Rynald0s](https://wordpress.org/support/users/rynald0s/)
 * (@rynald0s)
 * Automattic Happiness Engineer
 * [5 years, 9 months ago](https://wordpress.org/support/topic/minimum-order-amount-5/#post-13205112)
 * Hi [@stefanig](https://wordpress.org/support/users/stefanig/)!
 * The following code works for me, so maybe modify this to fit your specific needs.
 * In the case, I am requiring a minimum order value of $25 if the state is CA (
   California). It does not allow checkout. Instead, it displays an error that there
   is a problem in the cart, and the cart itself echoes the error message within
   the code:
 *     ```
       add_action( 'woocommerce_check_cart_items', 'wc_min_order_total' );
   
       function wc_min_order_total() {
   
       	if( is_cart() || is_checkout() ) {
       		global $woocommerce;
   
               $minimum = 25;
       	  	$state = array('CA');  //California
   
               $cart_tot_order = WC()->cart->total;
       		$state = $woocommerce->customer->get_shipping_state();
   
               if( $cart_total_order < $minimum  && $state == 'CA'  ) {
   
       	        wc_add_notice( sprintf( '<strong>A Minimum order of $%s is required before checking out.</strong>' 
       	        	. '<br />Current order: $%s.', $minimum, $cart_tot_order	), 'error' );
       		}
       	}
       }
       ```
   
 * You can extend the array and add more states if you like.
 * Cheers!
    -  This reply was modified 5 years, 9 months ago by [Rynald0s](https://wordpress.org/support/users/rynald0s/).
 *  Thread Starter [stefanig](https://wordpress.org/support/users/stefanig/)
 * (@stefanig)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/minimum-order-amount-5/#post-13206553)
 * [@rynald0s](https://wordpress.org/support/users/rynald0s/)
 * Тhank you so much, it works correctly! 🙂
 * Have a nice day! 🙂

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

The topic ‘Minimum order amount’ 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

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

 * 4 replies
 * 2 participants
 * Last reply from: [stefanig](https://wordpress.org/support/users/stefanig/)
 * Last activity: [5 years, 9 months ago](https://wordpress.org/support/topic/minimum-order-amount-5/#post-13206553)
 * Status: resolved