Latest Articles
So far this was never an issue, there were problems with uploading modules via the installer because of the ftp connection but you could allways install ocmods without any issue. However, some .. Read More
People had this issue so many times I thought I would write a bit about it. The  types of issues with opencart's 2.x modification system that I identified so far are: 1. Old Vqmod .. Read More
This small tutorial will show you how to manually add custom links to the default top menu in opencart. If you dont want to go trough all the hustle and would like to be able to completly customize.. Read More
To enable seo urls in opencart navigate in admin to system > settings , edit the store and on the server tab of the store settings you will find "Use SEO urls", set it to yes. So far e.. Read More
All Articles

Add to cart not working on opencart homepage

A very common problem that many users encounter is the Add to Cart sometimes not working on their site homepage.

The problem is related to the url of the store. A website can be accessed trough adress like: example.com as well as www.example.com

When you first install opencart, the base of the website is going to be written in config.php, but it can only be one: either example.com or www.example.com (depends on the adress you accessed the installation in the first place). So if you install your store by going to example.com, then the base of your website in config.php will be example.com. So here is the origin of the problem, because if you then access your store via www.example.com , the add to cart wont work on the homepage.

To fix this problem, you can make a redirect in htaccess from www.example.com to example.com or the other way around (depends on which case applies to you).

First, to make a redirect from non www to  www adress (ex: from example.com to www.example.com), edit the .htaccess from your opencart root and find the line:

 

RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

 

and below it add the code:

 

RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

 

To make a redirect from www to non www adress (ex: from www.example.com to example.com), edit the same file mentioned above, and below the same line mentioned, add the code:

 

RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule (.*) http://example.com/$1 [R=301,L]

 

In both cases, replace example.com with the adress of your store.

Posted by Flo

Related Articles

People had this issue so many times I thought I would write a bit about it. The  types of issues with opencart's 2.x modification system that I identified so far are: 1. Old Vqmod version installed which doesnt support ocmod 2. Ocmod cache could not be written due to insufficient folder permission 3. The ocmod cache doesnt get loaded in frontend (ocmod works in admin but not in frontend) The most common I encountered is number 3 because it has to do with the opecart installation method. Some control panel software installers do not properly configure the ope..
0 comments on this article - view comments