Post by LangQuest » Sat Mar 17, 2018 5:54 am

Hi,

I would like to change the “Continue Shopping” button on the shopping cart to point back to the referring page rather than the common/home page. The referring page is outside of Opencart. I found a file (/catalog/controller/checkout/cart.php which has an entry near the top of the file:

'href' => $this->url->link('common/home’),

Is this the entry that should be modified? If so, what should I change it to? I would like the customer to return to the product page (outside of Opencart) on which they clicked the “Add to Cart” button.

Newbie

Posts

Joined
Tue Mar 06, 2018 6:42 am

Post by straightlight » Sat Mar 17, 2018 6:43 am

No OC version posted. However, it can be done. Followed is for v3.0.2.0 release:

In catalog/controller/checkout/cart.php file,

find:

Code: Select all

$product_id = (int)$this->request->post['product_id'];
add below:

Code: Select all

$this->session->data['product_id'] = (int)$product_id;
Then, find:

Code: Select all

$data['continue'] = $this->url->link('common/home');
replace with:

Code: Select all

if (!empty($this->session->data['product_id'])) {
				$data['continue'] = $this->url->link('product/product', 'product_id=' . (int)$this->session->data['product_id']);
			} else {
				$data['continue'] = $this->url->link('common/home');
			}
Then, in catalog/controller/product/product.php file, find:

Code: Select all

$this->load->model('catalog/manufacturer');
add below:

Code: Select all

if (!empty($this->session->data['product_id'])) {
			unset ($this->session->data['product_id']);
		}
This should resolved the issue.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by LangQuest » Sat Mar 17, 2018 7:58 am

Thanks for your response.

Just to be sure. Will this work for a product listing that is outside of the Opencart system? And sorry, yes I am using Opencart 3.0.2.0 - but only for its cart and checkout. The Add to Button on a product page is not in Opencart.

Newbie

Posts

Joined
Tue Mar 06, 2018 6:42 am

Post by straightlight » Sat Mar 17, 2018 8:04 am

If you are referring to an API, then no, the provided code above would be from inside the platform only. Rather use the catalog/controller/api/cart.php file by instantiating a backward compatibility with an api_id in order to reflect the change over JSON to receive the response through AJAX instead. This methodology will avoid on redirecting the customer to any page but rather read the response from your remote page. ;)

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by LangQuest » Sat Mar 17, 2018 8:19 am

The call to opencart is made using an extension called "Add to Cart URL link + Multi Prod + Coupon (1.5/2.x/3.x)" :
https://www.opencart.com/index.php?rout ... n_id=11443

So, for example, the call to opencart from a product page (outside of opencart) is made using:
http://www.mysite.com/index.php?route=c ... quantity=1

Does this change anything in your analysis?

Thank you so much for your input and advice.

Newbie

Posts

Joined
Tue Mar 06, 2018 6:42 am

Post by LangQuest » Tue Mar 20, 2018 7:28 am

I am using opencart 3.0.2.0. In /catalog/controller/checkout/cart.php

I changed
$data['continue'] = $this->url->link('common/home’);
to
$data['continue'] = "javascript:history.back()";

It seems to work OK. Is there any downside to this implementation?

Newbie

Posts

Joined
Tue Mar 06, 2018 6:42 am

Post by IP_CAM » Tue Mar 20, 2018 7:51 am

is there any downside to this implementation
Well, the downside is, that you're talking about an expensive Custom Mod,
and this means, that nobody else would be able to know about it's doings.
It would therefore be much better, to contact the Seller, I assume, to get
your matters solved, commercial Extensions are not part of this here..
just figured... 8)
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

Post by straightlight » Sun Apr 01, 2018 10:09 pm

So, for example, the call to opencart from a product page (outside of opencart) is made using:
http://www.mysite.com/index.php?route=c ... quantity=1
It would change something, yes. The product_id and the quantity must be parameted as a POST request. Not as a GET request when using any API toward the OC cart.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by jokke86 » Thu Jul 02, 2020 5:08 pm

straightlight wrote:
Sat Mar 17, 2018 6:43 am
No OC version posted. However, it can be done. Followed is for v3.0.2.0 release:

In catalog/controller/checkout/cart.php file,

find:

Code: Select all

$product_id = (int)$this->request->post['product_id'];
add below:

Code: Select all

$this->session->data['product_id'] = (int)$product_id;
Then, find:

Code: Select all

$data['continue'] = $this->url->link('common/home');
replace with:

Code: Select all

if (!empty($this->session->data['product_id'])) {
				$data['continue'] = $this->url->link('product/product', 'product_id=' . (int)$this->session->data['product_id']);
			} else {
				$data['continue'] = $this->url->link('common/home');
			}
Then, in catalog/controller/product/product.php file, find:

Code: Select all

$this->load->model('catalog/manufacturer');
add below:

Code: Select all

if (!empty($this->session->data['product_id'])) {
			unset ($this->session->data['product_id']);
		}
This should resolved the issue.
Hello!

I've modified the 2 php files, but the "continue shopping" still redirects me to common/home.
I cleared all cache, but I'm using Journal 3 theme. I don't see why, but this could be the problem maybe?

Thanks for the help!!

Newbie

Posts

Joined
Fri Apr 13, 2018 10:26 pm
Who is online

Users browsing this forum: No registered users and 2 guests