Right, nice & easy one today but one that seems to trip up a lot of people who want to channel their customers around their OpenCart store. By default, OpenCart is not good for lead conversions but with this blog you will learn how to define which pages are shown after users login and logout.
This is a two-in-one kind of blog so just skip to the part you need if you don’t want it all!
How To Redirect User To OpenCart Homepage After Logging In
Now, when you (or your customer) logs into OpenCart they are immediately faced with the unimpressive Account section which has various links but I have had a few people ask me whether it is possible to make OpenCart redirect them to the homepage instead. And it is of course!
Open up the login controller file located at:
Now, in this file there are three redirects which you will need to change and all of them look like this:
$this->redirect($this->url->link('account/account', '', 'SSL'));
What this little script is doing is saying “when the user is logged in, change the url to end with this”. All we need to do is edit it to make it change to the homepage variable. So, just quickly change it to:
$this->redirect($this->url->link('common/home', '', 'SSL'));
Which is of course, the Route to the home page. If you don’t have SEO friendly URLS enabled in your OpenCart store you can easily find out the route of the page you are viewing because it will have it displayed openly.:
Now, the beauty with this is that we can put any route on your website in this, so you could redirect the OpenCart customer to the Order History page with ‘account/order’, special deals with ‘product/special’ or the contact page with ‘information/contact’. These are just examples of course! But now you know how to redirect to any OpenCart page on your website!
How To Redirect The OpenCart User To Any Domain After Logging In
Now, technically there is no reason to redirect the customer to another domain name after they have logged into your OpenCart store I thought I would show you how anyway!
All we need to do is take out the functions you don’t need and provide the URL directly to the redirect function as I have shown below:
Remember to put in ‘https‘ if the domain you are redirecting to has an SSL certificate!
How To Redirect OpenCart Customer On Logging Out
Now, this part is very useful in defining a custom page to show to your OpenCart visitor when they have logged out. By default OpenCart shows them some boring, and useless page which gives them permission to turn off their computer but that space can be very valuable in capturing visitors as they are leaving! You can define a custom information page with some special offers to encourage them to log back in and spend money or just display advertisements/affiliate ads to try and capture some revenue from your departing customers.
The same process applies as above, simply open up the logout controller file located at:
Open it up and it have just one redirect function which you will need to change and it looks like this:
$this->redirect($this->url->link('account/logout', '', 'SSL'));
It is about 20 lines down usually and all you need to do it change the route to follow such as:
//To show the home page after logging out $this->redirect($this->url->link('common/home', '', 'SSL'));
Or you can define an entirely new domain address with a full URL:
//To redirect to a new URL $this->redirect('http://www.jackwdavis.com');
And there we go, we have a chance to show whatever we want to customers logging out of your OpenCart store. As I mentioned earlier this is great for increasing customer conversions, boosting sales and customer loyalty! Let me know if you have any interesting uses for this or want anything clarifying!
Buy the vqMod file to redirect your customers to the homepage after logging in and out of OpenCart
You can download this lightweight vqMod file which redirects your customers to the homepage after logging in or out of OpenCart. Buying this mod allows me to keep on blogging and ensures that you can channel customers more effectively around the store without having to risk making any modifications to the core system. This has been tested with openCart 126.96.36.199 and works all for just £2.99!