I'm looking for a way to set a minimum quantity per product in a Drupal Commerce store.

I found this module which claims to do just this, but I can't get it working and the project seems abandoned:

I found this one which is useful if you need to set a minimum in the order but it doesn't help to set a minimum in products.

Is there any other way to do this?

  • A possible solution would be to add a custom validation for the field that checks if the minimum has been set. Example hook to use for a contenttype: mytype_node_form_validate() (and similarly mytype_node_form_submit() for the submit function). – Fons Vandamme Feb 16 '15 at 18:55
  • Ok, but will this validation works in the cart as well? The quantity can be changed in the cart too. – chefnelone Feb 17 '15 at 7:31
  • The cart is also a form right so you can also add the validation there. Correct me if i'm wrong. You could also check the UC code to get inspired on how to add this for commerce (drupal.org/project/uc_product_minmax) – Fons Vandamme Feb 17 '15 at 7:37
  • Problem is that this validation will be applied to all products. I need to set restriction per product. – chefnelone Feb 17 '15 at 8:00
  • You'll probably have to create a field per product that sets the minimum amount of products and then use this dynamically in your validation. – Fons Vandamme Feb 17 '15 at 8:09

I believe there's a quiet simple solution using rules. More specific based on the existing commerce_stock by default enabled rules : - Stock: validate add to cart - Stock: validate checkout These rules have both an action "Set the state of the checkout process (called once per item)", preventing add to cart or checkout when the stock conditions are not met.

In order to check line item quantity with on product level defined minimum order quantities, you can clone these rules and alter the rule conditions. There's a way to implement a custom rule condition using hook_rules_condition_info().

Example implementation could be :

* Implements hook_rules_condition_info().
function my_custommodule_rules_condition_info() {
  return array(
    'minimum_product_qty_applied' => array(
      'group' => t('Commerce Line item'),
      'label' => t('Min. product qty selected'),
      'parameter' => array(
        'commerce_line_item' => array(
          'type' => 'commerce_line_item',
          'label' => t('Commerce line item'),

function minimum_product_qty_applied($line_item) {
    return _check_minimum_product_qty($line_item); //returns TRUE or FALSE
| improve this answer | |

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.