Page 1 of 1

OpenCart 2.2.0.0 add to cart says "error, undefined"

Posted: Sun May 01, 2016 11:21 pm
by silkcamel
Hi All,

This is Opencart 2.2.0.0, clean version, just installed paypal express checkout module in payment section.
I'm trying to test the payment and add one product to cart, there is a pop up message shows:

This site says
Error
Underfined

Anybody has this issue and know what's the problem? Thank you!

Re: OpenCart 2.2.0.0 add to cart says "error, undefined"

Posted: Mon May 02, 2016 5:52 pm
by inactiveaccount9912
Does that happen on any page or just homepage? Could you post a link?

Re: OpenCart 2.2.0.0 add to cart says "error, undefined"

Posted: Mon May 02, 2016 10:28 pm
by silkcamel
florinsith,

link has been sent to you, please check your private message. Thanks.

Bill

Re: OpenCart 2.2.0.0 add to cart says "error, undefined"

Posted: Mon May 02, 2016 10:33 pm
by Qphoria
When you first visit your site, if you don't visit it as the url in your config.php file for HTTP_SERVER, ajax callbacks won't work because of same origin policy. The best way to handle this is to force www or non-www in your htaccess file to match what your config.php file has. If you use www in your config, force it in the htaccess, and vice versa.

According to stack overflow, this is the preferred way:

Code: Select all

RewriteEngine On
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Source:

Re: OpenCart 2.2.0.0 add to cart says "error, undefined"

Posted: Mon May 02, 2016 11:08 pm
by silkcamel
Hi Qphoria,

It's very clear for step1-6, I'll do that.

May I confirm the last step? just want to make sure I will do the right way.

1. find the .htaccess.txt in the public_html folder;
2. edit it by adding the coding your provided to line 31?
3. save it and rename the .htaccess.txt to .htaccess

see attached photos. Am I right?

Re: OpenCart 2.2.0.0 add to cart says "error, undefined"

Posted: Tue May 03, 2016 12:38 pm
by Qphoria
yes correct.

Re: OpenCart 2.2.0.0 add to cart says "error, undefined"

Posted: Tue May 03, 2016 10:44 pm
by silkcamel
Hi Qphoria,

I've completed those steps and it work, non-www redirected to www site. May I ask one more favor? how to have it redirected to https instead of http so that I can have padlock icon for every pages? right now every page is http not https.

(1) system/config/catalog.php had been edited per your instruction.
Do I need to edit the system/config/admin.php as well?
attached is the admin.php (just look like to same as catalog.php before editing.

Re: OpenCart 2.2.0.0 add to cart says "error, undefined"

Posted: Tue May 03, 2016 10:50 pm
by silkcamel
and attached are the

(1) modified .htacess file
(2) public_html/config.php
(3) public_html/admin/config.php

what coding should I add to have SSL padlock show to every pages, or at least homepage, checkout, payment pages?
PS: I've installed SSL certificate in the server.

Thank you very much

Re: OpenCart 2.2.0.0 add to cart says "error, undefined"

Posted: Wed May 04, 2016 12:18 am
by Qphoria
just set the http:// to https:// in the HTTP_SERVER value in the config.

Re: OpenCart 2.2.0.0 add to cart says "error, undefined"

Posted: Wed May 04, 2016 2:42 am
by silkcamel
Thanks Qphoria, you are the HERO.

This is just for other people who has the same issues. see markup as attached.

I edited the config.php in both root and admin folder. and it works, now, every pages goes to https:// and have padlock icon beside it.

Re: OpenCart 2.2.0.0 add to cart says "error, undefined"

Posted: Thu May 05, 2016 2:03 am
by civolis
Hi guys. I did all this tricks in my store but, in the checkout page I have a lot of 404 (file not found) in the js, css and images files. What could be happening?

In the store admin is defined to SSL true.

Bellow my htaccess in root and in folder store:
/.htaccess

Code: Select all

# Acesso http redirecionado para https
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www.(.*) [NC]
RewriteRule (.*) https://mydomain.com.br%{REQUEST_URI} [L,QSA]

RewriteCond %{HTTP_HOST} ^mydomain.com.br$ [NC,OR]
RewriteCond %{REQUEST_URI} !store/
RewriteCond %{REQUEST_URI} !loja/
RewriteRule (.*) /store/$1 [L]
/store/.htaccess

Code: Select all

RewriteBase /store/
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=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]

RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule ^(.*)$ index.php [F,L]

Re: OpenCart 2.2.0.0 add to cart says "error, undefined"

Posted: Sat Jul 16, 2016 6:06 am
by cc-cr
Hi

I have the same issue in opencast 2.2.0.0 , a user reported the "undefined error" when adding an item to the shopping cart. Prior to this my test had not shown this error.

reading the solution I have experimented further

the domain is used without www and then it works fine

if I use http://www.domain_name the error occurs.

When I add the lines as described above (very well described I like to add) this creates many problems the home page is completely garbled up.

there was initially no .htaccess file in my public_html folder


this is the beginning of config.php in the root

<?php

Code: Select all

// HTTP
define('HTTP_SERVER', 'http://funwithfido.co.uk/');

// HTTPS
define('HTTPS_SERVER', 'http://funwithfido.co.uk/');

// DIR
and this in the beginning of admin folder config.php file

Code: Select all

<?php
// HTTP
define('HTTP_SERVER', 'http://funwithfido.co.uk/admin/');
define('HTTP_CATALOG', 'http://funwithfido.co.uk/');

// HTTPS
define('HTTPS_SERVER', 'http://funwithfido.co.uk/admin/');
define('HTTPS_CATALOG', 'http://funwithfido.co.uk/');
advice on how to proceed is most welcome

Daniel

Re: OpenCart 2.2.0.0 add to cart says "error, undefined"

Posted: Fri Jul 29, 2016 12:24 pm
by Daniel
or another solution is replace the url class with the one from the master branch.

Re: OpenCart 2.2.0.0 add to cart says "error, undefined"

Posted: Fri Jul 29, 2016 7:51 pm
by nzbsa
As I have entire store in https://domain (no www) this redirect works perfect,
http and www is redirected straight to https://domain

You could customize to your needs

Code: Select all

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Re: OpenCart 2.2.0.0 add to cart says "error, undefined"

Posted: Tue Aug 02, 2016 11:15 am
by IP_CAM
and just to mention it, this .htaccess routing only functions, without producing 'too many rerouting' messages on Test Sites, if NO Image/Script Subdomain Routing has been defined, linked to the Shop Site.
Example:
---
http:// www. shopsite/shop_index.php (default Site Access)
---
Now, if an image/Script Subdomain Link would look like:
---
http:// shopsite/image/...
http:// scripts. shopsite/...
http:// images. shopsite/image/...
http:// scripts. shopsite/scripts/...
---
e.t.c., the images and Scripts would all be redirected as well by the .htaccess order, and called from:
---
http:// www. shopsite/...
http:// www. shopsite/image/...
http:// www. shopsite/scripts/...
---
e.t.c., because the .htaccess is ordered to do this, and therefore not longer be Cookie-free as well !
A Double Shot in the knee, kind of... :D

At least, if a SHOP is placed in the Site ROOT Section, and, therefore, only ONE .htaccess File exists,
for the Site and the Shop. But if a Shop is placed in a Subdirectory, above mentioned Findings
have NO effect, if the Site /ROOT/ .htaccess - WWW or no WWW - Site Rerouting is defined in the ROOT
Directory, and the ../Shop/ .htaccess File does NOT contain such specific rerouting Informations.

According to what I just found out, after placing my first test Shop in the Site ROOT Section. ;)

Ernie

This .htaccess File is, what I usually have in my HTML ROOT Section, to redirect everything
to WWW: where I have my master index.html HTML Page, serving as IFRAME-Masterpage,
to have the Responsive Demo Framepages working. It can be set either way, by QUOTING, what is not used.

Code: Select all

# Rabbit Rabbit Security Upgrade
Options +SymLinksIfOwnerMatch

# Prevent Directory listing 
Options -Indexes

# SEO URL Settings
RewriteEngine On
RewriteBase /

#Force (http host) www to non www (optional)
#RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
#RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

#Force (https host) www to non www (optional)
#RewriteCond %{HTTPS} on
#RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
#RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

#Force (http host) non www to www (optional)
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

#Force (https host) non www to www (optional)
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

#@__HCP_END__@#

Re: OpenCart 2.2.0.0 add to cart says "error, undefined"

Posted: Sat Aug 20, 2016 4:27 pm
by RachSobie
IP_CAM wrote:and just to mention it, this .htaccess routing only functions, without producing 'too many rerouting' messages on Test Sites, if NO Image/Script Subdomain Routing has been defined, linked to the Shop Site.
Example:
---
http:// www. shopsite/shop_index.php (default Site Access)
---
Now, if an image/Script Subdomain Link would look like:
---
http:// shopsite/image/...
http:// scripts. shopsite/...
http:// images. shopsite/image/...
http:// scripts. shopsite/scripts/...
---
e.t.c., the images and Scripts would all be redirected as well by the .htaccess order, and called from:
---
http:// www. shopsite/...
http:// www. shopsite/image/...
http:// www. shopsite/scripts/...
---
e.t.c., because the .htaccess is ordered to do this, and therefore not longer be Cookie-free as well !
A Double Shot in the knee, kind of... :D

At least, if a SHOP is placed in the Site ROOT Section, and, therefore, only ONE .htaccess File exists,
for the Site and the Shop. But if a Shop is placed in a Subdirectory, above mentioned Findings
have NO effect, if the Site /ROOT/ .htaccess - WWW or no WWW - Site Rerouting is defined in the ROOT
Directory, and the ../Shop/ .htaccess File does NOT contain such specific rerouting Informations.

According to what I just found out, after placing my first test Shop in the Site ROOT Section. ;)

Ernie

This .htaccess File is, what I usually have in my HTML ROOT Section, to redirect everything
to WWW: where I have my master index.html HTML Page, serving as IFRAME-Masterpage,
to have the Responsive Demo Framepages working. It can be set either way, by QUOTING, what is not used.

Code: Select all

# Rabbit Rabbit Security Upgrade
Options +SymLinksIfOwnerMatch

# Prevent Directory listing 
Options -Indexes

# SEO URL Settings
RewriteEngine On
RewriteBase /

#Force (http host) www to non www (optional)
#RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
#RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

#Force (https host) www to non www (optional)
#RewriteCond %{HTTPS} on
#RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
#RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

#Force (http host) non www to www (optional)
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

#Force (https host) non www to www (optional)
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

#@__HCP_END__@#
my site is non-www and HTTPS is not working. I have tried all of the steps above (changing config/ admin config, setting to true etc) and continually get the too many reroutes 500 error.
My site is in the route folder.
do I need to include the # from the above codes in the files?

Just to add I have added this code

Code: Select all

#Force (https host) www to non www (optional)
#RewriteCond %{HTTPS} on
#RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
#RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
changed the config/ admin config from HTTP to HTTPS and when I add to cart I get the error undefined message.
only the home page and checkout remain in HTTPS the otherpages all still revert to HTTP. Oh it remains as www. too so not redirecting to non-www

Re: OpenCart 2.2.0.0 add to cart says "error, undefined"

Posted: Sun Aug 21, 2016 12:48 am
by IP_CAM
# means, that this Line has just an informative Value, it's DISABLED from doing anything!
One can SWITCH OFF such lines, i.E., in order to leave a Routine in both ways, but only
use one of them, matching individual requirements. Like in this specific Sections,
where one has to either change to www. or no www.
Ernie

Re: OpenCart 2.2.0.0 add to cart says "error, undefined"

Posted: Sun Aug 21, 2016 5:25 pm
by RachSobie
IP_CAM wrote:# means, that this Line has just an informative Value, it's DISABLED from doing anything!
One can SWITCH OFF such lines, i.E., in order to leave a Routine in both ways, but only
use one of them, matching individual requirements. Like in this specific Sections,
where one has to either change to www. or no www.
Ernie
Thanks Ernie ;D