Post by ulrslo » Fri Nov 25, 2016 5:15 pm

Hi!
I will be very greatful for some advice.
We will have a add for a book on Facebook. And we want to add it automatically to cart when link i clicked in the add? Is it possible? So when they click on add, they should come to a page to just add shipping information.

Is it possible?
Best regards Ulrika

New member

Posts

Joined
Wed Mar 30, 2011 2:25 pm

Post by thekrotek » Fri Nov 25, 2016 6:55 pm

You need to add some variable to your link and then process it, when page loads. For example, your link can look like this:

Code: Select all

http://yourstore.com/index.php?route=product/product&product_id=1&action=add
This link will open your product page, but there's "action" variable here and you need to capture it. Just add a code to controller/product/product.php, which will check for "action" variable in the link:

Code: Select all

if ($this->request->get['action']) {
// Do stuff
}
If variable is found, add this product to cart. Guess, something like this should work:

Code: Select all

$this->cart->add($this->request->get['product_id']);
Then you can redirect the visitor anywhere you want. For example, to cart page:

Code: Select all

$this->response->redirect($this->url->link('checkout/cart'));
This is a very simple example, which will add 1 pc of a single product without any options. For more complex task you'll dig a little deeper and expand your code.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by IP_CAM » Sat Nov 26, 2016 9:18 am

or then, get an Extension for this:
---
Add to Cart via URL link (1.5.x/2.x.x)
https://www.opencart.com/index.php?rout ... n_id=11443
---
Utimate Add To Cart via URL
https://www.opencart.com/index.php?rout ... n_id=21707
---
Link Cart (Share Your Cart)
https://www.opencart.com/index.php?rout ... n_id=13731
---
Good Luck ! ;)
Ernie

My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland
Who is online

Users browsing this forum: No registered users and 1 guest