Page 1 of 1

only add the last "add to cart" product to basket

Posted: Sun Dec 20, 2009 10:00 am
by superuser
Dear All,

I'm thinking of allowing 1 product per order.

Thus, I wish to only add the last "add to chart" product to basket. I know there is a thread discussing on limiting the number of product in an order but that is not exactly what i want..


What I wish to get is:

Eg,

1. User chosen "Product A", "Product A" is added to the basket and proceed to shipping.
2. User continue to click on "Product B", "Product A" in basket will be removed and only "Product B" is shown in the basket.

Is this possible?

I have check the controller/checkout/cart.php and system/library/cart.php, but they are a bit complicated to me..

Re: only add the last "add to cart" product to basket

Posted: Sun Dec 20, 2009 1:53 pm
by Qphoria
1. EDIT: catalog/controller/checkout/cart.php

2. FIND:

Code: Select all

if (isset($this->request->post['quantity'])) {
3. BEFORE, ADD:

Code: Select all

$this->cart->clear();

Re: only add the last "add to cart" product to basket

Posted: Sun Dec 20, 2009 2:02 pm
by superuser
Qphoria wrote:1. EDIT: catalog/controller/checkout/cart.php

2. FIND:

Code: Select all

if (isset($this->request->post['quantity'])) {
3. BEFORE, ADD:

Code: Select all

$this->cart->clear();
Qphoria,

Thanks for being so helpful! :D