I am working in Drupal 7 in Ubercart 3, and I am looking for a way to set a minimum on the number of items that a user can have before being able to start the checkout process.
Is there a module out there that handles this need?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityI am working in Drupal 7 in Ubercart 3, and I am looking for a way to set a minimum on the number of items that a user can have before being able to start the checkout process.
Is there a module out there that handles this need?
There is Ubercart Product Minimum & Maximum
Adds minimum, maximum and order in multiples limits on products. Checks that the quantity selected matches the limits during both Add To Cart and Checkout actions. Quantity checks are disabled when product is added to the cart as part of a product kit.
If you want to do it with code this is one way to do that.
You can make use of hook_add_to_cart to get the product add event.
To get the number of items use uc_cart_get_contents
The ides is
function <modulename>_add_to_cart($nid, $qty, $data) {
$items = uc_cart_get_contents();
// Display a message if the cart has more than 5 products.
$item_count = count($items);
if ($item_count < 5) {
drupal_set_message('Your cart Should contains more than 5 products to checkout !');
// drupal_goto to product listing page
}
return $result;
}