lunar
lunar copied to clipboard
Min & Max Quantity
Is your feature request related to a problem? Please describe.
It would be great to be able to specify the min or max quantity of a given product or variant that a customer is allowed to purchase.
Perhaps it could be per order or the lifetime of a product as some products might be one-per-customer.
Describe the solution you'd like
Simple Min Max order quantity fields should suffice for the basic idea.
For control over if the limits are per order or lifetime might need more consideration but possibly simple checkboxes. I'm not sure how best to tackle the checks for per-order or lifetime but I did see the AddToCart
component in the store example that could be extended.
Describe alternatives you've considered
Adding events or changing validation at the add to cart process, however the fields will still be required.
Additional context The idea comes from something that I will be needing in a cart product. Products need to be limited per customer, it is a fairly standard feature in ecommerce platforms. One per customer over a lifetime is something that is difficult to find though, could be a nice addition.
I guess at a simple level it would be easy to achieve. You could even just do it with custom attributes.
The difficulty comes when trying to restrict maximum. As a customer could just place multiple orders etc. Defining the "rate limit" on that would be tricky.
I thought we already had min. qty though, @alecritson ?
@glennjacobs I think you're thinking of the old version. Doesn't look like it's on 2.0
So I think min. qty can be put in without too much further thought.
Max. qty is going to need to be defined somehow.
@alecritson would this be better served by allowing devs to add their own validation at the time of adding to a cart?
@AugmentBLU @alecritson @glennjacobs I've written a GetCandy Purchase Limit Addon for multiple kinds of purchase limits.
It injects some Rule classes into the Cart/CartLine modifiers pipeline to check various purchase limit rules against the current cart. You can even write your own rule classes to extend it's functionality.
You can define a criteria for each rule. Currently, these rules are implemented:
- by a specific product
- by a specific product variant
- by a customer or customer group
- by a specific product and customer/customer group
- by a specific product variant and customer/customer group
Each purchase limit rule allows you to restrict quantity, price, or both of them.
There is also an Admin Hub slot which you can register it in product edit page:
@glennjacobs @alecritson I think it's better to leave the core as it is currently and don't make it fat by such kind of features. Addons would be best suited for injecting such functionalities using either cart or order modifiers.
@armezit That looks pretty nice, unfortunately it doesn't appear to be working with a fresh install of GetCandy for some reason. I don't see any options anywhere and no errors are appearing in the log. I'll keep looking and will create a repo issue if you cannot replicate.
@armezit That looks pretty nice, unfortunately it doesn't appear to be working with a fresh install of GetCandy for some reason. I don't see any options anywhere and no errors are appearing in the log. I'll keep looking and will create a repo issue if you cannot replicate.
@AugmentBLU I will check it asap on a fresh installation to see what's going wrong. Still it would be great if you open an issue on the repo. Thanks