Skip to content

Instantly share code, notes, and snippets.

@vinaygopinath
Created February 16, 2014 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vinaygopinath/9038964 to your computer and use it in GitHub Desktop.
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
/*
* 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