Page 1 of 1
Cart Maximum Qty Values
Posted: Tue Nov 17, 2020 11:55 am
by mhsuffolk
Phoenix 1.0.5.0 PHP 7.3
I have the Maximum Values in Configuration for "Product Quantities In Shopping Cart" set to 1 as 99.99% of my customers buy many different DVDs but just 1 of each but sometimes revisit an item that is in the cart already, click Add to Cart again and inadvertently buy 2 copies.
However I would like the Qty Up/Down arrows to still function in the cart to cater for the very occasional customer who is buying a second copy for a friend etc. The maximum Values setting reverts any Qty changes back to 1
Is this achievable please?
Martin
Re: Cart Maximum Qty Values
Posted: Tue Nov 17, 2020 12:21 pm
by burt
I don't think you'll be able to have that as you are pulling in two directions in that tug of war;
pull to the right: limit buy ability to one
pull to the left: allow to buy more than one
Maybe the best way would be to have some type of message that says
"you have already bought this DVD"
That would only work for logged in customers though.
Re: Cart Maximum Qty Values
Posted: Tue Nov 17, 2020 3:27 pm
by ecartz
1. Get rid of the maximum quantity setting (or make it high enough to cover the rare cases).
2. Override the add_product action.
Replace
Code: Select all
$qty = (!empty($_POST['qty'])) ? (int)$_POST['qty'] : 1;
$_SESSION['cart']->add_cart($_POST['products_id'], $_SESSION['cart']->get_quantity(tep_get_uprid($pid, $attributes))+$qty, $attributes);
with
Code: Select all
$_SESSION['cart']->add_cart($_POST['products_id'], max(1, $_SESSION['cart']->get_quantity(tep_get_uprid($pid, $attributes))), $attributes);
The max is just to make sure that if there are already two items in the cart, you don't reduce the number when reaching the cart. Possibly add more logic to change the message when this happens (you already have this in your cart; if you really want to update the quantity, please do so on the cart page). Make a similar change to buy_now if desired. Do not change update_product, which is what is used from the cart page.
I believe that this will give the behavior that you describe or close to it.
Re: Cart Maximum Qty Values
Posted: Wed Nov 18, 2020 8:01 am
by mhsuffolk
Thank you for the replies, I will have a play later today and report back
Re: Cart Maximum Qty Values
Posted: Wed Nov 18, 2020 3:03 pm
by mhsuffolk
Sad to say I cannot get it to work.
It does not break anything but the behaviour does not change.