Post by derek » Thu Feb 09, 2012 3:20 pm

In this topic: http://forum.opencart.com/viewtopic.php?f=131&t=37180, the following URL is used to add multiple products to the cart (and the link does work correctly to add two products to the cart):
http://unbannable.com/v149x/index.php?r ... ntity[1]=2

I am using opencart 1.4.8 and the above link is probably working on version 1.4.9. I can only get this URL technique to work for single products. For example, the following URL correctly puts qty 3 of product #29 into my cart:
http://www.mywebsite.com/index.php?rout ... quantity=3

However, the next URL does not work; my cart reports the shopping cart is empty:
http://www.mywebsite.com/index.php?rout ... ntity[1]=2

Is this being caused by a difference between versions 1.4.8 and 1.4.9 ?

Does anyone know of a fix?

Newbie

Posts

Joined
Thu Aug 12, 2010 3:12 pm

Post by Qphoria » Thu Feb 09, 2012 11:52 pm

Yes I believe the GET method for add to cart was added in 1.4.9 or at least improved to allow multiple. You may be able to take the system/library/cart.php and catalog/controller/checkout/cart.php files from the latest 1.4.9 and use it with 1.4.8 but not sure.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by derek » Fri Feb 10, 2012 4:46 am

Thank you for that pointer.

I can go searching for the code changes but at this stage I wouldn't know how to recognize the relevant sections. Any clues please?

Newbie

Posts

Joined
Thu Aug 12, 2010 3:12 pm

Post by derek » Mon Feb 27, 2012 7:14 am

SOLUTION:

in catalog\controller\checkout\cart.php

Change line 8 from:
if ($this->request->server['REQUEST_METHOD'] == 'GET' && isset($this->request->get['product_id'])) {

to:
if ($this->request->server['REQUEST_METHOD'] == 'GET' && isset($this->request->get['product_id'][0])) {

AND line 45 from:
$this->cart->add($this->request->get['product_id'], $quantity, $option);

To:
$this->cart->add($this->request->get['product_id'][$i], $quantity, $option);

Hope someone finds this useful

Newbie

Posts

Joined
Thu Aug 12, 2010 3:12 pm

Post by mhafeezmm » Thu Nov 29, 2012 10:19 pm

Hi derek,

Is this for 1.4.9 only or can be used for 1.5.4.1 as well?

Thanks in advance :)

Newbie

Posts

Joined
Mon Jul 09, 2012 4:13 pm
Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot] and 82 guests