Created
February 16, 2014 18:59
-
-
Save vinaygopinath/9038964 to your computer and use it in GitHub Desktop.
A small tweak for the WooCommerce plugin for WordPress - This sets the minimum number of items to be present in the cart for checkout. Here's the error message in action: http://imgur.com/74BEhW5
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
/* | |
* Include this code in your theme's functions.php | |
*/ | |
add_action( 'woocommerce_checkout_process', 'wc_minimum_cart_count' ); | |
function wc_minimum_cart_count() { | |
global $woocommerce; | |
$minimum = 6; | |
if ( $woocommerce->cart->get_cart_contents_count() < $minimum ) { | |
$woocommerce->add_error( sprintf( 'You must have a minimum of %s items in your cart to place an order' , $minimum ) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment