Post by dim565 » Sun Mar 06, 2011 12:48 am

Hello. Sorry if I ask the last time too many questions. If someone can help - I will be grateful.
I want to be when you click add to cart on the page caterogy.tpl (a href="<?php echo $products[$j]['add']; ?>">) - the goods are not added to the basket to the existing elements and do not add the quantity of the previously added item.

ie that the basket was always one (last added) goods.

it is possible?

New member

Posts

Joined
Fri Feb 18, 2011 12:48 pm

Post by Qphoria » Thu Apr 28, 2011 9:19 pm

So you always want 1 item only for each item?

1. EDIT: system/library/cart.php

2. FIND:

Code: Select all

$this->session->data['cart'][$key] += (int)$qty;
3. REPLACE WITH:

Code: Select all

$this->session->data['cart'][$key] = (int)$qty;

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by dim565 » Thu Apr 28, 2011 9:48 pm

Thank you for trying to help, unfortunately this is not what I need
I want to delete function that when you add a product to the cart and there is already another product, then the new product is added to the old.

Instead, I need to make an old product is replaced by a new one. In other words, the buyer could buy for 1 time only one product (but in any quantity)

Attachments

Безымянный.png

Безымянный.png (64.7 KiB) Viewed 6741 times


New member

Posts

Joined
Fri Feb 18, 2011 12:48 pm

Post by dim565 » Fri Apr 29, 2011 8:34 pm

Please write at least where the code. which adds an item to Cart. But I really would grateful if someone writes a ready solution

New member

Posts

Joined
Fri Feb 18, 2011 12:48 pm

Post by Qphoria » Fri Apr 29, 2011 8:39 pm

So you want ONLY 1 type of product in the cart at one time and if another is added it deletes the existing products and replaces with the new one?

1. EDIT: system/library/cart.php

2a. FIND (1.4.x):

Code: Select all

if (!$options) {
2b. FIND (1.5.x):

Code: Select all

if (!$option) {
3. BEFORE, ADD:

Code: Select all

$this->clear();

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by dim565 » Fri Apr 29, 2011 9:04 pm

Yes! This is what I wanted! I did not think so simple, but without your help I would not do!
Qphoria, Thank you very much! :)

New member

Posts

Joined
Fri Feb 18, 2011 12:48 pm

Post by onlinephilately » Fri Jun 15, 2012 2:18 am

Q your first answer helped me a lot. thx!

Now, would it be possible to have this function (only allow one item per product) for all products except products with certain Manufacturer ID's?

New member

Posts

Joined
Thu Jan 27, 2011 3:14 am

Post by utgJ » Fri Jan 10, 2014 11:18 pm

Qphoria, would you mind letting me know how to achieve this on Opencart 1.5.6? Would be much appreciated if you could, thanks.

Newbie

Posts

Joined
Tue Nov 05, 2013 10:02 am

Post by brandd » Sat Nov 15, 2014 1:29 am

I tried this in OpenCart 1.5.6 but it does not work
Can you please help us
Would be much appreciated
Thanks

Newbie

Posts

Joined
Mon Jun 23, 2014 9:17 am

Post by soundslider » Sat Jun 01, 2019 7:10 pm

Hi all , please help me , how can i used this on Opencart 2.3 ?

Newbie

Posts

Joined
Tue Mar 27, 2018 10:13 am
Who is online

Users browsing this forum: Semrush [Bot] and 149 guests