Cart Maximum Qty Values

Post general questions here for help using CE Phoenix.
Post Reply
mhsuffolk
Phoenix Club
Phoenix Club
Posts: 9

Cart Maximum Qty Values

Post by mhsuffolk » Tue Nov 17, 2020 11:55 am

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.5.0 on PHP 7.3 Test Shop 1.0.5.2

burt
Lead Developer
Lead Developer
Posts: 726
Has thanked: 1 time

Re: Cart Maximum Qty Values

Post by burt » Tue Nov 17, 2020 12:21 pm

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.

ecartz
Lead Developer
Lead Developer
Posts: 525

Re: Cart Maximum Qty Values

Post by ecartz » Tue Nov 17, 2020 3:27 pm

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.

mhsuffolk
Phoenix Club
Phoenix Club
Posts: 9

Re: Cart Maximum Qty Values

Post by mhsuffolk » Wed Nov 18, 2020 8:01 am

Thank you for the replies, I will have a play later today and report back
Live shop Phoenix 1.0.5.0 on PHP 7.3 Test Shop 1.0.5.2

mhsuffolk
Phoenix Club
Phoenix Club
Posts: 9

Re: Cart Maximum Qty Values

Post by mhsuffolk » Wed Nov 18, 2020 3:03 pm

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.5.0 on PHP 7.3 Test Shop 1.0.5.2

Post Reply