Closed (won't fix)
Project:
Commerce Core
Version:
7.x-1.x-dev
Component:
Cart
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
18 Jan 2011 at 10:27 UTC
Updated:
5 Jun 2012 at 08:28 UTC
It should be implemented in the field formatter and in the add to cart form views handler.
Use case:
You have a store that sells file downloads, and you want to prevent users from buying more than 1 of the same item. With the cart as view patch you can remove the quantity field from the cart view/form. But users still can add multiple items of the same product to the cart by clicking several times on the "Add to cart" button.
Comments
Comment #1
pcambraThis won't prevent "advanced" user from adding additional items even if the form button is not there.
I think we may should add a global setting for "disallow users to buy more than one item from a given product" which would turn these formatter options automatically. This should check the "Add to cart" action and validate the number of items added.
We would need an extra formatter setting for turning the add to cart into a remove from cart or just hide the button.
Comment #2
rszrama commentedOne possible way to restrict this would be through Rules... on the "After adding a product to the cart" event, you can check the quantity of the new line item. If it's greater than 1, you can update the quantity to 1 and display a message that the customer has already added that to their cart.
Comment #3
recidive commentedOk, so we presumably can do this with rules.
@rszrama: do you think it makes sense turning the "Add to cart" button into "Remove from cart" button? And an option to just hide it completely?
Comment #4
recidive commentedTagging.
Comment #5
recidive commentedComment #6
rszrama commentedI think it's a nice feature for a contributed module - I did something similar with "UC Restrict Qty" for Ubercart. I'm going to close this for now in preference of the Rules solution and to keep the core simpler.
Comment #7
denisr commentedActually, it looks like that "After adding a product to the cart" trigger does not work. It is quite a while that I am trying to achieve the same result with Rules
Comment #8
johnpitcairn commentedAnyone wishing to implement something like this may find the following useful. Adapted from sample code at http://www.agileadam.com/add-to-cart-tweaks. Not intended as all-purpose generic module code, use at your own risk.