This relates to a post I made here How do I copy a "purchase limit" field from a product to a product line item

Situation: We are building a commerce website using Drupal 7 and Drupal Commerce for a government agency that distributes free publications

They have a limit on the number of free items that can be ordered at once, (unless the person ordering has a good reason.)

We have a field called copy limit on our product entities.

If the user enters a quantity on the” add to cart “for that exceeds the copy limit, we want the order to go into a holding area after the order is completed for further review.

Our plan is to use a taxonomy term to do this. We have a vocabulary called "Is this a bulk order?" It has two terms, yes and no.

We want to have it so if the quantity in one of the line items in a customer's order exceeds the copy limit, the term reference field for the "Is this a bulk order" vocabulary is set to yes.

Also (I'm not sure if this belongs here but....)

In a related question, we are trying to get the user fill out a field if the copy limit is exceeded explaining why they need to exceed the limit. We have a field on the order called "Bulk Order Explanation"

Right now, I have rule that after saving a new line item, and the quantity exceeds the copy limit, the user is brought to a add content page for a content type I called "Bulk Order Explanation"

What we want to happen is that after they save the "Bulk Order Explanation" node, the body of the content type is used to populate the bulk order explanation field.

I am not even sure if I am headed in the right direction on either of these things. Thanks for any insight you can provide!

  • First, I think you probably want a custom field on the line item or order (most likely line item?) that marks it as bulk order. I don't see taxonomy being as useful here. Second, please try to ask only one question in a post. You can link between them as you did here.
    – rfay
    Oct 20, 2011 at 19:30
  • On your "bulk order explanation", why not make that a field on the line item? You'll have to figure out a way to get it there, but there should be a way. In a perfect world, it would only show when they put a high quantity and would be updated by ajax, but that would defintely require code...
    – rfay
    Oct 20, 2011 at 19:33
  • I experimented a bit yesterday but didn't get to a full solution; I do think this strategy will work. And a simple extra pane would be great for this.
    – rfay
    Oct 21, 2011 at 21:11

1 Answer 1


Here's a strategy that I think will work:

  • Create a field on the product like field_bulk_order_limit
  • Create a field on the order called "field_held_bulk_order" or something. This can be a boolean or some similar thing.
  • Create a rule that looks at the product's field_bulk_order limit whenever a line item is created or updated and its product has that field. It could output to the screen (system: site message) at the user if the number is above the bulk order limit.
  • Create a checkout rule (a rule triggered by "when completing the checkout process") that loops through the line items and checks their products' field_bulk_order_limit. If it finds line items with a quantity higher than the field_bulk_order_limit, set the order's field_held_bulk_order to TRUE. Optionally also show them another message.
  • Fiddle with your administrative order views to have a view that explicitly shows held orders,etc.
  • Nice to have: create a custom pane that lets them enter the reason that they need so many. This requires a tiny module. It could imitate the commerce_order.module's pane (see commerce_order.checkout_pane.inc and commerce_order_commerce_checkout_pane_info()
  • I understand most of the logic behind this, and have created the first rule, but I am having trouble with the second rule. I cannot figure out how to load the quanity of the products or the copy limit. I have the copy limit value being trasfered to the line items. Oct 26, 2011 at 14:59
  • That's an OK technique IMO. In rules you have to bring referenced entities into scope with "Entity has field". So you'd need two conditions on this rule. Line item has field "commerce product" and then Line Item:Commerce Product has field field_bulk_order_limit. Then you'd be able to add a third condition that said "If quantity > bulk order limit" and an action that sets the flag on the order.
    – rfay
    Oct 27, 2011 at 16:35
  • And for the "nice to have" there is now a checkout pane example in the Commerce Examples project, drupal.org/project/commerce_examples
    – rfay
    Oct 27, 2011 at 16:36
  • Thanks Randy, your idea worked pretty well with one addition. In the loop, I referenced a rule component that checks the quantity and copy lime fields against each other. Dec 1, 2011 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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