I am using Ubercart 2 on Drupal 6 with http://drupal.org/project/uc_product_minmax. It works well, except for the fact that the default catalog only provides an 'Add to cart' button with no quantity field, and the quantity it adds is 1, which makes it useless as the minimum order quantity in this particular case is 2.

I have tried implementing hook_add_to_cart() to forcefully change $qty to 2 if it's lower only to find that I cannot manipulate it before uc_product_minmax implements the hook, so I'm in need of an alternative.

Maybe this isn't even fixable without modifying uc_product_minmax itself, but I'm up for trying any other ideas.


If you want to alter the cart item, then you can use hook_uc_cart_alter of ubercart.

This is called every time the cart is rebuild (e.g. when products are added), so it's a good place to alter the cart item.

Code snippets to modify the qty of the item

 * Implements uc_cart_alter.
function mymodule_uc_cart_alter(&$items ) {

  foreach ($items as $index => $item) {

   //you can add condition for your product

    $items[$index]->qty = 2;

For reference:



enter image description here

Here you see this.we have default option for quantity when we add product in drupal .we make this is 2.

  • Thanks, unfortunately though that doesn't fix the issue as that setting only affects the quantity field and not the behaviour of the "Add to cart" button in the catalog. I suppose this could be considered a bug, but then the minimum order quantity is introduced with a separate module and to have this setting affect the standalone button as well probably wouldn't make much sense without it. I think I need a way of doing this in code. – Riari Aug 22 '12 at 8:51
  • Could you give me an screen shot... to understand properly. – Lav Rai Aug 22 '12 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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