Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
i have a price table with different pricing per quantity. However, even if my lowest qty is 100, i can still add 1 item to the cart using the qty field. How can i (rules or otherwise) set this limit? nothing has worked so far
thanks!!
Comment | File | Size | Author |
---|---|---|---|
#7 | moq_field_on_product.png | 153.11 KB | vegantriathlete |
Comments
Comment #1
funkeyrandy CreditAttribution: funkeyrandy commentedif anyone needs this here is the rule i used to compare the min price table quantity with the current cart qty trying to be added:
cheers!
Comment #3
msrc_spinks CreditAttribution: msrc_spinks commentedDo you have any details on using this? I added the rule but it isn't going into effect.
Comment #4
vegantriathleteNotice the dependencies for the rule: You must have the php filter enabled (BAD IDEA!) and you must also have commerce_rules_extra.
I used the idea of adding commerce_rules_extra to get the event of updating a line item quantity. But, then I wrote my own custom rules condition to check that the line item meets the minimum order quantity. I also used the Entity Delete action to remove the line item from the cart if the user attempted to set the quantity to less than the MOQ.
Comment #5
vegantriathleteDefine a custom condition
Code the callback for the condition
NOTE: I happen to have a field attached to each product that specifies the MOQ. So, I'm not actually looking at the product price table.
Comment #6
Summit CreditAttribution: Summit commentedHi @vegantriathlete,
What sort of field is it you add to your product, and is it named field_moq ?
Can you also remove the line then...Product added to shoppingcard...because this is not the case if minimum quantity is not met?
Thanks for answering in advance!
Greetings, Martijn
Comment #7
vegantriathlete@Summit
I added a plain text field to the product.
I don't understand your next question. I've got a custom condition that checks for MOQ. If the condition is false, then the action that is triggered is the Entity Delete to remove the line item.
Comment #8
joknjokn CreditAttribution: joknjokn commentedHi. Thank you for the Rule. It works fine, except that it's possible to update the qunatity in the cart-view. The warning-message still appears, but the quantity is set to what ever the user chooses.
Any idea how to fix this?
Comment #9
funkeyrandy CreditAttribution: funkeyrandy commentedi disabled the qty field in the cart view :)
Comment #10
Andreas Radloff CreditAttribution: Andreas Radloff commentedSlightly related, I have just published a module for limiting the minimum quantity based on a multiplier so you're only allowed to add, say, 10s of items to your cart. https://www.drupal.org/project/commerce_fixed_quantity
Comment #11
funkeyrandy CreditAttribution: funkeyrandy commentedNICE!!
Comment #12
joknjokn CreditAttribution: joknjokn commentedI made a rule that fits my needs.
If the quantity of a line item becomes lower than the lowest interval-amount of the Price Table, but not 0, the quantity of the line item is set to the lowest interval-amount (minimum quantity), and displays an informative message to the user. It works both on the product display-page and when updating the cart at the View cart-page.
I don't think my solution is efficient, using PHP-condition, but I don't know what else to do.
The cleaned php-eval: