Cart Maximum Qty Values

Ask the community for help and support.
Post Reply
User avatar
mhsuffolk
VIP Member
VIP Member
Posts: 146
Joined: Sat Oct 26, 2019 9:13 am
Has thanked: 8 times
Been thanked: 5 times

Cart Maximum Qty Values

Post 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
Live shop Phoenix 1.0.9.0 on PHP 8.0
burt
Lead Developer
Lead Developer
Posts: 2423
Joined: Tue Oct 29, 2019 9:37 am
Has thanked: 48 times
Been thanked: 137 times

Re: Cart Maximum Qty Values

Post 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.
Gamechanger Addon: Queued Emails, try before you buy.
ecartz
Lead Developer
Lead Developer
Posts: 2637
Joined: Tue Nov 05, 2019 6:02 pm
Has thanked: 4 times
Been thanked: 181 times

Re: Cart Maximum Qty Values

Post 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.
User avatar
mhsuffolk
VIP Member
VIP Member
Posts: 146
Joined: Sat Oct 26, 2019 9:13 am
Has thanked: 8 times
Been thanked: 5 times

Re: Cart Maximum Qty Values

Post by mhsuffolk »

Thank you for the replies, I will have a play later today and report back
Live shop Phoenix 1.0.9.0 on PHP 8.0
User avatar
mhsuffolk
VIP Member
VIP Member
Posts: 146
Joined: Sat Oct 26, 2019 9:13 am
Has thanked: 8 times
Been thanked: 5 times

Re: Cart Maximum Qty Values

Post by mhsuffolk »

Sad to say I cannot get it to work.
It does not break anything but the behaviour does not change.
Live shop Phoenix 1.0.9.0 on PHP 8.0
Post Reply