Post by ianhaney50 » Sat Dec 07, 2024 4:10 pm

I am using opencart 3.0.4.0 for a new site and everything is working and using a theme called electronic and having a issue where the delete button is not refreshing/updating the shopping cart page and so the product stays there when the button is clicked. I have to refresh the page and then product is removed from the shopping cart page

It does it on the default theme as well and I remember it did it on the opencart 2.3.0.2 site I used to have but I can't remember what I did to solve it

Active Member

Posts

Joined
Fri Apr 29, 2016 4:21 am

Post by JNeuhoff » Sat Dec 07, 2024 7:08 pm

It works with the default theme on OC 3.0.4.0, see e.g. our demo site. Hence you should contact the theme author. Or provide a link to your OpenCart site here if you want some more help.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by ianhaney50 » Sat Dec 07, 2024 7:47 pm

Ahh ok sounds like it's theme related, the link to the site is https://www.it-doneright.co.uk/shop/

I'll also contact the theme developer to see if they can help too

Active Member

Posts

Joined
Fri Apr 29, 2016 4:21 am

Post by nonnedelectari » Sat Dec 07, 2024 8:42 pm

ianhaney50 wrote:
Sat Dec 07, 2024 7:47 pm
Ahh ok sounds like it's theme related, the link to the site is https://www.it-doneright.co.uk/shop/

I'll also contact the theme developer to see if they can help too
You made your cart url SEO friendly and did not adjust the ajax logic in common.js accordingly.
That logic does not expect an SEO friendly url for the cart and will therefore not redirect properly, as in not at all.

Active Member

Posts

Joined
Thu Mar 04, 2021 6:34 pm

Post by ianhaney50 » Sat Dec 07, 2024 9:16 pm

Ahh ok, I have updated the code in the common.js file but it didn't work

From

Code: Select all

if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
					location = 'index.php?route=checkout/cart';
				} else {
					$('#cart > ul').load('index.php?route=common/cart/info ul li');
				}

TO (This is what I had in the 2.3.0.2 common.js file

Code: Select all

                if ($(location).attr('href') == 'https://www.it-doneright.co.uk/shop/cart' || $(location).attr('href') == 'https://www.it-doneright.co.uk/shop/checkout') {
					location = 'index.php?route=checkout/cart';
				} else {
					$('#cart > ul').load('index.php?route=common/cart/info ul li');
				}

Active Member

Posts

Joined
Fri Apr 29, 2016 4:21 am

Post by nonnedelectari » Sat Dec 07, 2024 9:23 pm

ianhaney50 wrote:
Sat Dec 07, 2024 9:16 pm
Ahh ok, I have updated the code in the common.js file but it didn't work

From

Code: Select all

if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
					location = 'index.php?route=checkout/cart';
				} else {
					$('#cart > ul').load('index.php?route=common/cart/info ul li');
				}

TO (This is what I had in the 2.3.0.2 common.js file

Code: Select all

                if ($(location).attr('href') == 'https://www.it-doneright.co.uk/shop/cart' || $(location).attr('href') == 'https://www.it-doneright.co.uk/shop/checkout') {
					location = 'index.php?route=checkout/cart';
				} else {
					$('#cart > ul').load('index.php?route=common/cart/info ul li');
				}
May we assume you cleared your caches? Your browser cache in particular?

Active Member

Posts

Joined
Thu Mar 04, 2021 6:34 pm

Post by ianhaney50 » Sat Dec 07, 2024 9:27 pm

nonnedelectari wrote:
Sat Dec 07, 2024 9:23 pm
ianhaney50 wrote:
Sat Dec 07, 2024 9:16 pm
Ahh ok, I have updated the code in the common.js file but it didn't work

From

Code: Select all

if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
					location = 'index.php?route=checkout/cart';
				} else {
					$('#cart > ul').load('index.php?route=common/cart/info ul li');
				}

TO (This is what I had in the 2.3.0.2 common.js file

Code: Select all

                if ($(location).attr('href') == 'https://www.it-doneright.co.uk/shop/cart' || $(location).attr('href') == 'https://www.it-doneright.co.uk/shop/checkout') {
					location = 'index.php?route=checkout/cart';
				} else {
					$('#cart > ul').load('index.php?route=common/cart/info ul li');
				}
May we assume you cleared your caches? Your browser cache in particular?
Yeah I've cleared the cache in firefox and the cache from cloudflare but I set a rule in cloudflare to ignore the shop directory but I cleared the cache anyway within cloudflare

Active Member

Posts

Joined
Fri Apr 29, 2016 4:21 am

Post by nonnedelectari » Sat Dec 07, 2024 9:37 pm

Personally I would just put something like this in htaccess or your httpd.conf:

Code: Select all

RewriteRule ^shop/cart$ index.php?route=checkout/cart [L]
RewriteRule ^shop/checkout$ index.php?route=checkout/checkout [L]
then you can leave the javascript with all those hardcoded references alone.

Normally I would not recommend to put SEO url logic in htaccess but for the checkout and account paths, which OC explicitly excluded for good reason, that is often the best way in OC as many ajax call have hardcoded references to the non-SEO urls.
On the other hand, SEO urls for paths which will never be indexed by SEs is rather futile, they are called SEO urls for a reason.

Active Member

Posts

Joined
Thu Mar 04, 2021 6:34 pm

Post by ianhaney50 » Sat Dec 07, 2024 9:48 pm

nonnedelectari wrote:
Sat Dec 07, 2024 9:37 pm
Personally I would just put something like this in htaccess or your httpd.conf:

Code: Select all

RewriteRule ^shop/cart$ index.php?route=checkout/cart [L]
RewriteRule ^shop/checkout$ index.php?route=checkout/checkout [L]
then you can leave the javascript with all those hardcoded references alone.

Normally I would not recommend to put SEO url logic in htaccess but for the checkout and account paths, which OC explicitly excluded for good reason, that is often the best way in OC as many ajax call have hardcoded references to the non-SEO urls.
On the other hand, SEO urls for paths which will never be indexed by SEs is rather futile, they are called SEO urls for a reason.
I have put the original code back in the common.js file and added the two lines you mentioned to the htaccess file (I put them just under the RewriteBase /shop/ line

I've cleared the cache again but still got the same issue

Active Member

Posts

Joined
Fri Apr 29, 2016 4:21 am

Post by nonnedelectari » Sat Dec 07, 2024 10:29 pm

Well, maybe put:

Code: Select all

console.log(getURLVar('route'));
before that redirect logic and see what it says in your web dev tools console when you click remove.
Your cart update seems to work but remove still goes to https://www.it-doneright.co.uk/shop/ind ... /cart/info which means it does not recognize the checkout/cart or checkout/checkout url.

Active Member

Posts

Joined
Thu Mar 04, 2021 6:34 pm

Post by ianhaney50 » Sat Dec 07, 2024 10:50 pm

nonnedelectari wrote:
Sat Dec 07, 2024 10:29 pm
Well, maybe put:

Code: Select all

console.log(getURLVar('route'));
before that redirect logic and see what it says in your web dev tools console when you click remove.
Your cart update seems to work but remove still goes to https://www.it-doneright.co.uk/shop/ind ... /cart/info which means it does not recognize the checkout/cart or checkout/checkout url.
I'll try that but have since been advised by the developer of the theme that it's best to have the site on a subdomain such as shop.domain.co.uk then I won't run into issues as they said having the opencart site in a subfolder such as /shop/ it will generate issues

Active Member

Posts

Joined
Fri Apr 29, 2016 4:21 am

Post by nonnedelectari » Sat Dec 07, 2024 11:13 pm

ianhaney50 wrote:
Sat Dec 07, 2024 10:50 pm
nonnedelectari wrote:
Sat Dec 07, 2024 10:29 pm
Well, maybe put:

Code: Select all

console.log(getURLVar('route'));
before that redirect logic and see what it says in your web dev tools console when you click remove.
Your cart update seems to work but remove still goes to https://www.it-doneright.co.uk/shop/ind ... /cart/info which means it does not recognize the checkout/cart or checkout/checkout url.
I'll try that but have since been advised by the developer of the theme that it's best to have the site on a subdomain such as shop.domain.co.uk then I won't run into issues as they said having the opencart site in a subfolder such as /shop/ it will generate issues
nonsense, you can run multiple OC sites in subfolders, besides, not sure how long you have been running this but moving to a sub domain might impact your ranking.

Active Member

Posts

Joined
Thu Mar 04, 2021 6:34 pm

Post by ianhaney50 » Sat Dec 07, 2024 11:49 pm

nonnedelectari wrote:
Sat Dec 07, 2024 11:13 pm
ianhaney50 wrote:
Sat Dec 07, 2024 10:50 pm
nonnedelectari wrote:
Sat Dec 07, 2024 10:29 pm
Well, maybe put:

Code: Select all

console.log(getURLVar('route'));
before that redirect logic and see what it says in your web dev tools console when you click remove.
Your cart update seems to work but remove still goes to https://www.it-doneright.co.uk/shop/ind ... /cart/info which means it does not recognize the checkout/cart or checkout/checkout url.
I'll try that but have since been advised by the developer of the theme that it's best to have the site on a subdomain such as shop.domain.co.uk then I won't run into issues as they said having the opencart site in a subfolder such as /shop/ it will generate issues
nonsense, you can run multiple OC sites in subfolders, besides, not sure how long you have been running this but moving to a sub domain might impact your ranking.
It's not been running long and not had many sales on it to be honest so not too worried as hopefully it will start ranking for the new subdomain

Active Member

Posts

Joined
Fri Apr 29, 2016 4:21 am

Post by ianhaney50 » Sun Dec 08, 2024 1:15 am

nonnedelectari wrote:
Sat Dec 07, 2024 10:29 pm
Well, maybe put:

Code: Select all

console.log(getURLVar('route'));
before that redirect logic and see what it says in your web dev tools console when you click remove.
Your cart update seems to work but remove still goes to https://www.it-doneright.co.uk/shop/ind ... /cart/info which means it does not recognize the checkout/cart or checkout/checkout url.
Sorry where do I put the line

Code: Select all

console.log(getURLVar('route'));
Is that in the htaccess file or the common.js file. Do I need to also put the code back in for the seo url cart and checkout?

Active Member

Posts

Joined
Fri Apr 29, 2016 4:21 am

Post by ianhaney50 » Sun Dec 08, 2024 1:31 am

nonnedelectari wrote:
Sat Dec 07, 2024 10:29 pm
Well, maybe put:

Code: Select all

console.log(getURLVar('route'));
before that redirect logic and see what it says in your web dev tools console when you click remove.
Your cart update seems to work but remove still goes to https://www.it-doneright.co.uk/shop/ind ... /cart/info which means it does not recognize the checkout/cart or checkout/checkout url.
I put the code back into the common.js file and tried again and looked at the console log in firefox and it says the following when I clicked the delete button

POST
https://shop.it-doneright.co.uk/index.p ... art/remove

GET
https://shop.it-doneright.co.uk/index.p ... /cart/info

I was unsure if I need to also add them two lines of code back into the htaccess file and unsure where to put the other code

Code: Select all

console.log(getURLVar('route'));
as well

Active Member

Posts

Joined
Fri Apr 29, 2016 4:21 am

Post by ianhaney50 » Sun Dec 08, 2024 2:02 am

I've put the following code back into the common.js file but it's not showing anything in the console tab in firefox

Code: Select all

console.log(getURLVar('route'));
                if ($(getURLVar).attr('route') == 'https://shop.it-doneright.co.uk/cart' || $(getURLVar).attr('route') == 'https://shop.it-doneright.co.uk/checkout') {
					location = 'index.php?route=checkout/cart';
				} else {
					$('#cart > ul').load('index.php?route=common/cart/info ul li');
				}
Not sure if I need to alter the code as not 100% at complicated code

Active Member

Posts

Joined
Fri Apr 29, 2016 4:21 am

Post by ianhaney50 » Sun Dec 08, 2024 2:41 am

I've checked the console log in chrome but it's already got two errors showing before I clicked the delete button

The errors it shows are below
Uncaught (in promise) Error: QUOTA_BYTES quota exceeded
Uncaught (in promise) Error: Could not establish connection. Receiving end does not exist.

Active Member

Posts

Joined
Fri Apr 29, 2016 4:21 am

Post by JNeuhoff » Sun Dec 08, 2024 5:39 am

It looks like your electronics theme uses its own common.js:

catalog/view/theme/electronic/js/common.js

it doesn't use the

catalog/view/javascript/common.js

Hence, changing the latter won't make any difference.

In any case, you shouldn't use SEO Urls for the checkout cart events in the first place, they are of no interest to the search engines.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by ianhaney50 » Sun Dec 08, 2024 6:19 am

JNeuhoff wrote:
Sun Dec 08, 2024 5:39 am
It looks like your electronics theme uses its own common.js:

catalog/view/theme/electronic/js/common.js

it doesn't use the

catalog/view/javascript/common.js

Hence, changing the latter won't make any difference.

In any case, you shouldn't use SEO Urls for the checkout cart events in the first place, they are of no interest to the search engines.
Ahh that did it but after it refreshed the page, it shows a The page you requested cannot be found.

The url is https://shop.it-doneright.co.uk/://DOMAIN_ROOT/cart which is because of a extension I installed called /ocmod.space/seo_common_urls from https://www.opencart.com/index.php?rout ... n_id=45444 unless there is another way I can remove the index.php?route=common/home from the home page URL etc

Active Member

Posts

Joined
Fri Apr 29, 2016 4:21 am

Post by nonnedelectari » Sun Dec 08, 2024 11:05 am

ianhaney50 wrote:
Sun Dec 08, 2024 6:19 am
JNeuhoff wrote:
Sun Dec 08, 2024 5:39 am
It looks like your electronics theme uses its own common.js:

catalog/view/theme/electronic/js/common.js

it doesn't use the

catalog/view/javascript/common.js

Hence, changing the latter won't make any difference.

In any case, you shouldn't use SEO Urls for the checkout cart events in the first place, they are of no interest to the search engines.
Ahh that did it but after it refreshed the page, it shows a The page you requested cannot be found.

The url is https://shop.it-doneright.co.uk/://DOMAIN_ROOT/cart which is because of a extension I installed called /ocmod.space/seo_common_urls from https://www.opencart.com/index.php?rout ... n_id=45444 unless there is another way I can remove the index.php?route=common/home from the home page URL etc
yes, in seo_url controller, search for it as it has been addressed many times, sure there is a free extension for it as well.

Active Member

Posts

Joined
Thu Mar 04, 2021 6:34 pm
Who is online

Users browsing this forum: lockiedownunder and 14 guests