Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

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?

Thank you for any help!

share|improve this question
add comment

1 Answer 1

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;
}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.