Created
February 3, 2015 11:41
-
-
Save ChromeOrange/33af495f6afdd5d7a397 to your computer and use it in GitHub Desktop.
Set a minimum order amount in WooCommerce and disable checkout page if it is not met
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'woocommerce_check_cart_items', 'wc_minimum_order_amount' ); | |
function wc_minimum_order_amount() { | |
// Set this variable to specify a minimum order value | |
$minimum = 50; | |
if ( WC()->cart->total < $minimum ) { | |
WC()->add_error( sprintf( 'You must have an order with a minimum of %s to place your order, your current order total is %s.' , | |
woocommerce_price( $minimum ), | |
woocommerce_price( WC()->cart->total ) | |
) ); | |
} | |
} |
how can I set minimum order amount depending on country?
add_action( 'woocommerce_check_cart_items', 'wc_minimum_order_amount' );
function wc_minimum_order_amount() {
// Set this variable to specify a minimum order value for a specific country
$minimum = 50;
$county = array('US');
if ( WC()->cart->total < $minimum && in_array( WC()->customer->get_shipping_country(), $county ) {
WC()->add_error( sprintf( 'You must have an order with a minimum of %s to place your order, your current order total is %s.' ,
woocommerce_price( $minimum ),
woocommerce_price( WC()->cart->total )
) );
}
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how to I can get value minimum amout of free shipping method in checkout page ?