Page 1 of 1
Add to Cart Not Working
Posted: Tue Mar 17, 2020 2:14 am
by brian47374
Well, I did a search on Add to Cart and it told me that it is too common and I went through 10 pages.... Anyways, I have OC 3.0.3.2 and the add to cart button is not working with the default theme. Any ideas?
Re: Add to Cart Not Working
Posted: Tue Mar 17, 2020 2:35 am
by letxobnav
My guess would be a CORS issue.
Re: Add to Cart Not Working
Posted: Tue Mar 17, 2020 2:38 am
by brian47374
What is CORS?
Re: Add to Cart Not Working
Posted: Tue Mar 17, 2020 2:46 am
by letxobnav
https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
you probably are mixing either urls with http and https or www and non-www or both.
Re: Add to Cart Not Working
Posted: Tue Mar 17, 2020 5:51 am
by brian47374
Is having a mixed url that is supposed to be SEO friendly normal in 3.0.3.2? I am running another site on 2.0.3.2 and the urls are clean looking. Below is the one that I am having trouble with.
https://curtistacticalsuppressorsandrif ... ct_id=1921
And, my host provider supposedly inserted the code in the .htaccess file that should have resolved the CORS problem. Well, that's what they said. lol
Re: Add to Cart Not Working
Posted: Tue Mar 17, 2020 2:38 pm
by cedcommerceteam
brian47374 wrote: ↑Tue Mar 17, 2020 2:14 am
Well, I did a search on Add to Cart and it told me that it is too common and I went through 10 pages.... Anyways, I have OC 3.0.3.2 and the add to cart button is not working with the default theme. Any ideas?
Hello mate,
Please provide us site URL so that we can analyze the exact issue as the information given by you is not sufficient.
Thanks!!!
Re: Add to Cart Not Working
Posted: Tue Mar 17, 2020 3:46 pm
by thekrotek
You'd better provide a link to your store with the issue. Otherwise it's just a guessing contest.
Re: Add to Cart Not Working
Posted: Tue Mar 17, 2020 4:10 pm
by letxobnav
he already has and a long one it is.
It's not CORS but I think it would be your htaccess as you links are screwed up.
add to cart ajax call goes to ?route=...... instead of index.php?route=....
Re: Add to Cart Not Working
Posted: Tue Mar 17, 2020 4:25 pm
by thekrotek
letxobnav wrote: ↑Tue Mar 17, 2020 4:10 pm
It's not CORS but I think it would be your htaccess as you links are screwed up.
add to cart ajax call goes to ?route=...... instead of index.php?route=....
It actually goes right, but returns 302 (permanent redirect) error.
Re: Add to Cart Not Working
Posted: Tue Mar 17, 2020 5:18 pm
by letxobnav
yep, goes from
POST
https://curtistacticalsuppressorsandrif ... t/cart/add
to
GET
https://curtistacticalsuppressorsandrif ... t/cart/add
temp redirect
still think its htaccess
and wrong cache headers
Date: Tue, 17 Mar 2020 09:11:11 GMT
Expires: Tue, 24 Mar 2020 09:11:11 GMT
Re: Add to Cart Not Working
Posted: Tue Mar 17, 2020 6:23 pm
by paulfeakins
Re: Add to Cart Not Working
Posted: Tue Mar 17, 2020 11:21 pm
by brian47374
Search for:
Integral
Rifle
Pistol
Re: Add to Cart Not Working
Posted: Wed Mar 18, 2020 9:19 am
by brian47374
Here is the .htaccess file at the public_html root level
Code: Select all
RewriteOptions inherit
# 1.To use URL Alias you need to be running apache with mod_rewrite enabled.
# 2. In your opencart directory rename htaccess.txt to .htaccess.
# For any support issues please visit: http://www.opencart.com
Options +FollowSymlinks
# Prevent Directoy listing
Options -Indexes
# Prevent Direct Access to files
<FilesMatch "(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))">
Require all denied
## For apache 2.2 and older, replace "Require all denied" with these two lines :
# Order deny,allow
# Deny from all
</FilesMatch>
# SEO URL Settings
RewriteEngine On
#redirect to https without www
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/
Code: Select all
RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteRule ^system/download/(.*) index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
# Enable Compression
<IfModule mod_deflate.c>
# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
# Remove browser bugs (only needed for really old browsers)
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
</IfModule>
# END Enable Compression
# Enable Browser Caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType text/css "access plus 1 week"
ExpiresByType application/pdf "access plus 1 week"
ExpiresByType text/x-javascript "access plus 1 week"
ExpiresByType application/x-shockwave-flash "access plus 1 week"
ExpiresByType image/x-icon "access plus 1 week"
ExpiresDefault "access plus 1 week"
</IfModule>
## END Enable Browser Caching
# BEGIN Cache-Control Headers
<ifModule mod_headers.c>
<filesMatch "\.(ico|jpe?g|png|gif|swf)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch "\.(css)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch "\.(js)$">
Header set Cache-Control "private"
</filesMatch>
<filesMatch "\.(x?html?|php)$">
Header set Cache-Control "public, must-revalidate"
</filesMatch>
</ifModule>
### Additional Settings that may need to be enabled for some servers
### Uncomment the commands by removing the # sign in front of it.
### If you get an "Internal Server Error 500" after enabling any of the following settings, restore the # as this means your host doesn't allow that.
# 1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it:
# php_flag register_globals off
# 2. If your cart has magic quotes enabled, This may work to disable it:
# php_flag magic_quotes_gpc Off
# 3. Set max upload file size. Most hosts will limit this and not allow it to be overridden but you can try
# php_value upload_max_filesize 999M
# 4. set max post size. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value post_max_size 999M
# 5. set max time script can take. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_execution_time 200
# 6. set max time for input to be recieved. Uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_input_time 200
# 7. disable open_basedir limitations
# php_admin_value open_basedir none
# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php7_module>
php_value max_input_time 60
php_value max_input_vars 1000000
php_value post_max_size 200M
php_value default_charset "UTF-8;"
php_value memory_limit 2064M
php_value max_execution_time 36000
php_value upload_max_filesize 999M
php_value mysql.connect_timeout 20
php_flag session.auto_start Off
php_flag session.use_only_cookies On
php_flag session.use_cookies On
php_flag session.use_trans_sid Off
php_value session.cookie_httponly "On;"
php_value session.gc_maxlifetime 3600
php_flag display_errors Off
php_value session.save_path "/var/cpanel/php/sessions/ea-php71"
php_flag zlib.output_compression On
</IfModule>
# END cPanel-generated php ini directives, do not edit
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^index\.php$ "https\:\/\/curtistacticalsuppressorsandrifles\.com\/" [R=302,L]
Re: Add to Cart Not Working
Posted: Wed Mar 18, 2020 10:37 am
by letxobnav
don't do this as it will cache for 1 week anything which is not otherwise specified like html in your case
Code: Select all
ExpiresDefault "access plus 1 week"
always set default expire is now
and then specify the specific types which should be cached longer
and don't do this as that is where your 302 redirects come from
Code: Select all
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^index\.php$ "https\:\/\/curtistacticalsuppressorsandrifles\.com\/" [R=302,L]
and this
Code: Select all
#redirect to https without www
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
write it like this
Code: Select all
# force ssl for non-binaries
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} !.*\.(ico|cur|mp3|webp|svg|ttf|eot|woff|woff2|gif|jpg|JPG|jpeg|JPEG|png)$
RewriteRule ^(.*)$ https://curtistacticalsuppressorsandrifles.com/$1 [R=301,L,NE]
# redirect any request having www to ssl without www
RewriteCond %{HTTP_HOST} ^www\.curtistacticalsuppressorsandrifles\.com [NC]
RewriteRule ^(.*)$ https://curtistacticalsuppressorsandrifles.com/$1 [L,R=301]
bottomline, don't blindly copy htaccess snipplets from the internet and expect them to work.
Re: Add to Cart Not Working
Posted: Wed Mar 18, 2020 10:47 am
by letxobnav
if you want
index.php?route=common/home to go away just add this
Code: Select all
} elseif ($data['route'] == 'common/home') {
$url = '/';
just before this in catalog/controller/startup/seo_url.php
Code: Select all
} elseif ($key == 'path') {
$categories = explode('_', $value);
Re: Add to Cart Not Working
Posted: Fri Mar 20, 2020 3:20 am
by brian47374
Thanks for the replies. I am not the htaccess expert, but I hope that I made the right changes in the right places. Not sure if I need to do anything at the end where I have it in bold.
Code: Select all
RewriteOptions inherit
# 1.To use URL Alias you need to be running apache with mod_rewrite enabled.
# 2. In your opencart directory rename htaccess.txt to .htaccess.
# For any support issues please visit: http://www.opencart.com
Options +FollowSymlinks
# Prevent Directoy listing
Options -Indexes
# Prevent Direct Access to files
<FilesMatch "(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))">
Require all denied
## For apache 2.2 and older, replace "Require all denied" with these two lines :
# Order deny,allow
# Deny from all
</FilesMatch>
# SEO URL Settings
RewriteEngine On
#redirect to https without www
# force ssl for non-binaries
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} !.*\.(ico|cur|mp3|webp|svg|ttf|eot|woff|woff2|gif|jpg|JPG|jpeg|JPEG|png)$
RewriteRule ^(.*)$ https://curtistacticalsuppressorsandrifles.com/$1 [R=301,L,NE]
# redirect any request having www to ssl without www
RewriteCond %{HTTP_HOST} ^www\.curtistacticalsuppressorsandrifles\.com [NC]
RewriteRule ^(.*)$ https://curtistacticalsuppressorsandrifles.com/$1 [L,R=301]
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/
RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteRule ^system/download/(.*) index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
# Enable Compression
<IfModule mod_deflate.c>
# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
# Remove browser bugs (only needed for really old browsers)
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
</IfModule>
# END Enable Compression
# Enable Browser Caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType text/css "access plus 1 week"
ExpiresByType application/pdf "access plus 1 week"
ExpiresByType text/x-javascript "access plus 1 week"
ExpiresByType application/x-shockwave-flash "access plus 1 week"
ExpiresByType image/x-icon "access plus 1 week"
ExpiresDefault "A0"
</IfModule>
## END Enable Browser Caching
# BEGIN Cache-Control Headers
<ifModule mod_headers.c>
<filesMatch "\.(ico|jpe?g|png|gif|swf)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch "\.(css)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch "\.(js)$">
Header set Cache-Control "private"
</filesMatch>
<filesMatch "\.(x?html?|php)$">
Header set Cache-Control "public, must-revalidate"
</filesMatch>
</ifModule>
### Additional Settings that may need to be enabled for some servers
### Uncomment the commands by removing the # sign in front of it.
### If you get an "Internal Server Error 500" after enabling any of the following settings, restore the # as this means your host doesn't allow that.
# 1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it:
# php_flag register_globals off
# 2. If your cart has magic quotes enabled, This may work to disable it:
# php_flag magic_quotes_gpc Off
# 3. Set max upload file size. Most hosts will limit this and not allow it to be overridden but you can try
# php_value upload_max_filesize 999M
# 4. set max post size. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value post_max_size 999M
# 5. set max time script can take. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_execution_time 200
# 6. set max time for input to be recieved. Uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_input_time 200
# 7. disable open_basedir limitations
# php_admin_value open_basedir none
# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php7_module>
php_value max_input_time 60
php_value max_input_vars 1000000
php_value post_max_size 200M
php_value default_charset "UTF-8;"
php_value memory_limit 2064M
php_value max_execution_time 36000
php_value upload_max_filesize 999M
php_value mysql.connect_timeout 20
php_flag session.auto_start Off
php_flag session.use_only_cookies On
php_flag session.use_cookies On
php_flag session.use_trans_sid Off
php_value session.cookie_httponly "On;"
php_value session.gc_maxlifetime 3600
php_flag display_errors Off
php_value session.save_path "/var/cpanel/php/sessions/ea-php71"
php_flag zlib.output_compression On
</IfModule>
# END cPanel-generated php ini directives, do not edit
RewriteCond %{HTTP_HOST} ^.*$
[b]RewriteRule ^index\.php$ "https\:\/\/curtistacticalsuppressorsandrifles\.com\/" [R=302,L][/b]
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php73” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php73 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
Re: Add to Cart Not Working
Posted: Fri Mar 20, 2020 12:53 pm
by letxobnav
move this
to right after
lose this:
Code: Select all
<filesMatch "\.(x?html?|php)$">
Header set Cache-Control "public, must-revalidate"
</filesMatch>
add this
Code: Select all
AddOutputFilterByType DEFLATE application/json
after
Code: Select all
AddOutputFilterByType DEFLATE application/xhtml+xml
this
should be this
directly after
why is this still there?
Code: Select all
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^index\.php$ "https\:\/\/curtistacticalsuppressorsandrifles\.com\/" [R=302,L]
lose it.
Re: Add to Cart Not Working
Posted: Thu Mar 26, 2020 4:28 am
by brian47374
Well, that worked! I truly do appreciate your help and patience!!!
I just checked the URL issue and it is still putting in a non SEO friendly ending on when it comes to the products. It seems to be slightly better than it was... lol
https://curtistacticalsuppressorsandrif ... ct_id=1919
Re: Add to Cart Not Working
Posted: Thu Mar 26, 2020 9:27 am
by letxobnav
check if product 1919 actually has seo keywords defined.