I am trying to Integrate the Cart into a Website. However, the Website already has a front end.
I need a way to add product with(if possible) configurable options into cart using a query string.
Example
1. From the Front End, i will send link like
http://www.example.com/opencart/index.p ... duct_id=49
This is an interesting idea. I think we could develop this commercially for you, if you would be happy to pay for our time.
If you'd like to talk it through some more please email me at matt.davies@itwiz.co.uk.
Regards
Matt
Matt Davies
www.itwiz.co.uk | matt.davies@itwiz.co.uk
Now it will be just like that:
Code: Select all
http://www.site.com/index.php?route=checkout/cart&product_id=40&quantity=1
No toes stepped on, thats great news. Is 1.4.8 out already? I'm really looking forward to using it!
Regards
Matt
Matt Davies
www.itwiz.co.uk | matt.davies@itwiz.co.uk
Not that what you have described already Q isn't already awesome, will that query string accept multiple adds in one swoop?
Code: Select all
http://www.site.com/index.php?route=checkout/cart&product_id1=40&qty1=1&product_id2=42&qty2=2....

Currently developing an awesome eBay integration extension for Open Cart
Demo is Live!
You can checkout screenshots and other development status on my website
Norman in 't Veldt
Moderator OpenCart Forums
_________________ READ and Search BEFORE POSTING _________________
Our FREE search: Find your answer FAST!.
[How to] BTW + Verzend + betaal setup.
I'm been looking for info on adding to the Cart using a Query String.
The sample posted works, http://www.site.com/index.php?route=che ... d=40&qty=1
but only adds one item to the cart.
I've tried:
http://www.site.com/index.php?route=che ... =48&qty2=1
http://www.site.com/index.php?route=che ... 48&qty_2=1
for multiple products with no success.
I'm guessing that the variables are incorrect for multiple product/qty.
I'm assuming the controller level in the previous post means modifying the code in the php script?
Any help or relevant links would be appreciated.
I'm working with a photobook program that opens a URL with a product id and page count.
I have a script that will calculate the number of pages and pass that value to the cart.
I can create the URL with the first product_id and quantity based on the example above.
The sample URL is http://www.mysite.com/checkout/index.ph ... quantity=1
I can't seem to figure out how to add the second product_id and quantity to cart via the URL.
Thanks.
My next step is to look at the cart.php and see if I can step through the array.
Code: Select all
<HTML>
<HEAD>
<TITLE>OpenCart Test</TITLE>
</HEAD>
<BODY>
<H1>OpenCart Test</H1>
<form action="http://www.yoursite.com/checkout/index.php" method="get" enctype="multipart/form-data">
<INPUT TYPE="Hidden" NAME="route" VALUE="checkout/cart"/>
<INPUT TYPE="Hidden" NAME="product_id[]" VALUE="40"/>
<INPUT TYPE="Hidden" NAME="quantity[]" VALUE="2"/>
<INPUT TYPE="Hidden" NAME="product_id[]" VALUE="48"/>
<INPUT TYPE="Hidden" NAME="quantity[]" VALUE="5"/>
<INPUT TYPE="SUBMIT" NAME="button" VALUE="Get">
</FORM>
</BODY>
</HTML>
Code: Select all
public function index() {
$this->language->load('checkout/cart');
if ($this->request->server['REQUEST_METHOD'] == 'GET' && isset($this->request->get['product_id'][0])) {
$myresult=count($_GET["product_id"]);
FOR ($i="0";$i<$myresult;$i++)
{
if (isset($this->request->get['option'][$i])) {
$option = $this->request->get['option'][$i];
} else {
$option = array();
}
if (isset($this->request->get['quantity'][$i])) {
$quantity = $this->request->get['quantity'][$i];
} else {
$quantity = 1;
}
unset($this->session->data['shipping_methods']);
unset($this->session->data['shipping_method']);
unset($this->session->data['payment_methods']);
unset($this->session->data['payment_method']);
$this->cart->add($this->request->get['product_id'][$i], $quantity, $option);
}
$this->redirect(HTTPS_SERVER . 'index.php?route=checkout/cart');
} elseif ($this->request->server['REQUEST_METHOD'] == 'POST') {
I ran across your code and gave it a try, but it's not working for me. If I use this URL:jfeher wrote:I was able to modify /catalog/controller/checkout/cart.php to process the multiple items and quantities in the querystring.
Code: Select all
http://localhost:8888/opencart/index.php?route=checkout/cart&product_id=5887&quantity=2&product_id=6447&quantity=2&product_id=6454&quantity=4
Is my URL formatted incorrectly?
Thanks,
Marc
OpenCart v1.4.9.4
VQMod | Categories Home | Cleaner By Default - 2 Column | Speak Good English
Thanks,
Marc
OpenCart v1.4.9.4
VQMod | Categories Home | Cleaner By Default - 2 Column | Speak Good English
Code: Select all
http://localhost:8888/opencart/index.php?route=checkout/cart&product_id[]=5887&quantity=2&product_id[]=6447&quantity=2&product_id[]=6454&quantity=4
Any ideas?
OpenCart v1.4.9.4
VQMod | Categories Home | Cleaner By Default - 2 Column | Speak Good English

Code: Select all
http://localhost:8888/opencart/index.php?route=checkout/cart&product_id[0]=5887&quantity[0]=2&product_id[1]=6447&quantity[1]=3&product_id[2]=6454&quantity[2]=4
BTW, a good PHP book is worth it's weight in gold. I'm reading "Beginning PHP 5.3" by Matt Doyle and just got to the section on arrays and that's what helped me figure this out.
Marc
Edit: I've added a vqmod with jfeher's code, in case anyone else wants to do this.
OpenCart v1.4.9.4
VQMod | Categories Home | Cleaner By Default - 2 Column | Speak Good English
Code: Select all
http://localhost:8888/opencart/index.php?route=checkout/cart&model[0]=4D-2448-7P&quantity[0]=2&model[1]=1D-2448-P&quantity[1]=3&model[2]=S2448P&quantity[2]=4
Marc
OpenCart v1.4.9.4
VQMod | Categories Home | Cleaner By Default - 2 Column | Speak Good English
marc_cole wrote:I've been trying to modify this to work with the model # instead of product_id, but I'm not having any luck. Does anyone else know how to make this work?Thanks,Code: Select all
http://localhost:8888/opencart/index.php?route=checkout/cart&model[0]=4D-2448-7P&quantity[0]=2&model[1]=1D-2448-P&quantity[1]=3&model[2]=S2448P&quantity[2]=4
Marc
Just to let you know, http://localhost:8888/ means only people on your computer/server can see it. Screen shots or a live test server would help the sharing.
Users browsing this forum: No registered users and 10 guests