Post by angela » Tue Dec 06, 2016 12:31 am

In category.tpl I changed:

Code: Select all

<button type="button" onclick="cart.add('<?php echo $product['product_id']; ?>', '<?php echo $product['minimum']; ?>');"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $button_cart; ?></span></button>
to:

Code: Select all

<a href="index.php?route=checkout/cart/add&product_id=<?php echo $product['product_id']; ?>&quantity=<?php echo $product['minimum']; ?>" method="get"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $button_cart; ?></span></a>
Upon visiting the link, the page background loads, with only:
[ ]
as content. Any way to get this to add the quantity to the cart and show the updated cart?

User avatar
New member

Posts

Joined
Fri Dec 02, 2016 2:14 am

Post by opencartmart » Tue Dec 06, 2016 1:50 am

Good try! this will not work.

What is your goal actually? Do you want to redirect to the cart page after being added product into cart?

XForm - Opencart Form Builder

Xshippingpro - An advanced Shipping Module


Active Member

Posts

Joined
Wed Oct 02, 2013 3:59 am

Post by angela » Tue Dec 06, 2016 2:52 am

Is there a way to make it work? :)

For the purpose of linking in newsletters, for example, clicking the 'Add to Cart' button like exampled above, auto-adds the item to your cart.

User avatar
New member

Posts

Joined
Fri Dec 02, 2016 2:14 am

Post by Qphoria » Tue Dec 06, 2016 3:56 am

There is a mod that does just what you need here https://www.opencart.com/index.php?rout ... n_id=11443

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by angela » Tue Dec 06, 2016 4:05 am

Qphoria wrote:There is a mod that does just what you need here https://www.opencart.com/index.php?rout ... n_id=11443
I'm not currently using OpenCart on a live site, so I'm not at the point I'm ready to pay for any extensions. Thanks though.

User avatar
New member

Posts

Joined
Fri Dec 02, 2016 2:14 am

Post by opencartmart » Tue Dec 06, 2016 1:52 pm

Let me try. In the file catalog/controller/checkout/cart.php , find the function add() and insert following code after $json = array();

Code: Select all

if (isset($this->request->get['product_id']) && isset($this->request->get['quantity'])) {
   $this->request->post['product_id'] = $this->request->get['product_id']; 
   $this->request->post['quantity'] = $this->request->get['quantity']; 
}
Finally insert following lines of code before the line $this->response->addHeader('Content-Type: application/json'); inside same function i.e add()

Code: Select all

if (isset($this->request->get['product_id']) && isset($this->request->get['quantity'])) {
	$redirect = isset($json['redirect']) ? $json['redirect'] : $this->url->link('checkout/cart');
	$this->response->redirect($redirect);
}
Your link should work now. Noted that I did not get a chance to test code.

XForm - Opencart Form Builder

Xshippingpro - An advanced Shipping Module


Active Member

Posts

Joined
Wed Oct 02, 2013 3:59 am
Who is online

Users browsing this forum: No registered users and 5 guests