If found an older thread which told me how to do what im looking for, but it did not work for me.
I am using 1.495 and I want to add to cart from an external page,
http://www.teststore/index.php?route=ch ... quantity=1
I tried that above but it just took me the shopping cart which was empty.
Any Ideas?
Thanks
I am using 1.495 and I want to add to cart from an external page,
http://www.teststore/index.php?route=ch ... quantity=1
I tried that above but it just took me the shopping cart which was empty.
Any Ideas?
Thanks
Is this what you're looking for?
http://forum.opencart.com/viewtopic.php?t=14960
I think this has been disabled for 1.5x, but I've used it on 1.4.9.2.
Just need to change "www.site.com" to your site, and the product id (40) to your product's id number.
http://forum.opencart.com/viewtopic.php?t=14960
I think this has been disabled for 1.5x, but I've used it on 1.4.9.2.
Code: Select all
http://www.site.com/index.php?route=checkout/cart&product_id=40&quantity=1
I usually forget to mention I'm using OC v1.4.9.4
You are going to want to go into your cart.php file within the checkout folder. Once in there you want to set up a check for certain GET variables set in your URL. This would be done inside the public function index() { Now, you have power to do really anything you want. You can call any function you wish inside that file to add, delete, update items to your cart. Or you can add something to your cart on the spot inside the if statement.
AMENDED CODE UPDATE
Just run a check and execute the code in the index function at the top somewhere like this:
AMENDED CODE UPDATE
Code: Select all
http://www.yoursite.com/index.php?route=checkout/cart&productid=40&quantity=1
Code: Select all
if(isset($this->request->get['productid']) && isset($this->request->get['quantity'])){
//add to the cart
$this->cart->add($this->request->get['productid'], $this->request->get['quantity'], $option = array());
//you can leave the 3rd $option argument alone..
}
Hi Avvici
I have followed your post and changed cart.php found under catalog/controller/checkout with your code in the top.
However, I get following errors:
Thanks in anticipation.
I have followed your post and changed cart.php found under catalog/controller/checkout with your code in the top.
However, I get following errors:
Code: Select all
Warning: Invalid argument supplied for foreach() in /home/exlors/public_html/intelliproducts.co.uk/tempcart/catalog/controller/checkout/cart.php on line 19Warning: Cannot modify header information - headers already sent by (output started at /home/exlors/public_html/intelliproducts.co.uk/tempcart/index.php:104) in /home/exlors/public_html/intelliproducts.co.uk/tempcart/vqmod/vqcache/vq2-system_engine_controller.php on line 28Warning: Cannot modify header information - headers already sent by (output started at /home/exlors/public_html/intelliproducts.co.uk/tempcart/index.php:104) in /home/exlors/public_html/intelliproducts.co.uk/tempcart/vqmod/vqcache/vq2-system_engine_controller.php on line 29
Hi Avvici
I have changed cart.php under catalog/controller/checkout folder.. below is the part of code; I have added the code to top of public function index() as below:
I have changed cart.php under catalog/controller/checkout folder.. below is the part of code; I have added the code to top of public function index() as below:
Code: Select all
public function index() {
$this->language->load('checkout/cart');
if(isset($this->request->get['productid']) && isset($this->request->get['quantity'])){
//add to the cart
$this->cart->add($this->request->get['productid'], $this->request->get['quantity'], $option);
//you can leave the 3rd $option argument alone..
}
if (!isset($this->session->data['vouchers'])) {
$this->session->data['vouchers'] = array();
}
// Update
if (!empty($this->request->post['quantity'])) {
foreach ($this->request->post['quantity'] as $key => $value) {
$this->cart->update($key, $value);
}
unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
unset($this->session->data['reward']);
$this->redirect($this->url->link('checkout/cart'));
}
// Remove.....
No, it's because your URL is not passing the info like I suggested. Your url:
Correct url:
Code: Select all
http://www.intelliproducts.co.uk/tempcart/index.php?route=checkout/cart
Code: Select all
http://www.site.com/index.php?route=checkout/cart&product_id=40&quantity=1
Hi Avvici
I updated the said code and now it takes me to the page but does not add anything and says shopping cart empty.
I have put:
I updated the said code and now it takes me to the page but does not add anything and says shopping cart empty.
I have put:
Code: Select all
<form action="http://www.intelliproducts.co.uk/tempcart/index.php?route=checkout/cart&product_id=50&quantity=1 method="post">
<input type="submit" name="submit" class="submit" />
</form>
Guys, everyone, you are directing towards a URL not a FORM URL.
http://www.yoursite.com/index.php?route ... quantity=1
Don't stick that url in a form lol. Make it a basic <a href
WRONG: <form action="http://www.intelliproducts.co.uk/tempca ... quantity=1 method="post">
<input type="submit" name="submit" class="submit" />
</form>
http://www.yoursite.com/index.php?route ... quantity=1
Don't stick that url in a form lol. Make it a basic <a href
WRONG: <form action="http://www.intelliproducts.co.uk/tempca ... quantity=1 method="post">
<input type="submit" name="submit" class="submit" />
</form>
Yes, this works using a url-link (get).
However I experience strange things with quantity, adding quantity 1 (one) of the article with this link:
I end up with one in cart. Now I delete the one in the cart and try again.
Now I have quantity 2 (two) of the article. Delete and try again.
Quantity 3 (three).
etc, etc.
irbe
However I experience strange things with quantity, adding quantity 1 (one) of the article with this link:
Code: Select all
http://www.mydomain.eu/webshop/index.php?route=checkout/cart&productid=52&quantity=1
Now I have quantity 2 (two) of the article. Delete and try again.
Quantity 3 (three).
etc, etc.
irbe
I made an error in the code that will in fact throw an error so here it the corrected code:
As far as your particular problem what version of Open Cart are you using? What you are describing is impossible. The only way that you are aggregating a quantity in the cart like that is if the URL in your browser is not changing after you delete. You are in fact using a GET so the quantity=1 is going to be there and take affect.
Code: Select all
if(isset($this->request->get['productid']) && isset($this->request->get['quantity'])){
//add to the cart
$this->cart->add($this->request->get['productid'], $this->request->get['quantity'], $option = array());
//you can leave the 3rd $option argument alone..
}
Pleas let me up this topic.
Avvici, I have done all those thing.
I add code to cart.php
After I try to use link
http://www.novyjrazum.ru/store/index.ph ... quantity=1
but in IE I have an error: Access is denied.
Help me fix this problem pleas.
Version 1.5.3.1 of OpenCart
Avvici, I have done all those thing.
I add code to cart.php
Code: Select all
public function index() {
$this->language->load('checkout/cart');
if(isset($this->request->get['productid']) && isset($this->request->get['quantity'])){
//add to the cart
$this->cart->add($this->request->get['productid'], $this->request->get['quantity'], $option = array());
//you can leave the 3rd $option argument alone..
}
if (!isset($this->session->data['vouchers'])) {
$this->session->data['vouchers'] = array();
}
http://www.novyjrazum.ru/store/index.ph ... quantity=1
but in IE I have an error: Access is denied.
Help me fix this problem pleas.
Version 1.5.3.1 of OpenCart
Who is online
Users browsing this forum: No registered users and 182 guests