Post by qtwrk » Thu Jun 01, 2017 7:04 am

Hi , I'm on 2.3.0.2 and I installed , and tried sevaral SEO mods that makes URL from

Code: Select all

index.php?route=checkout/cart
into , for example,

Code: Select all

cart.html
but one problem I noticed is that , with SEO URL changed , when you remove items in cart , the page doesn't refresh itself to show the change.

I guess is that "remove button" doesn't know the new URL to redirect/refresh.

so could anyone please tell me how to do it ?

I mean , when click "remove" button , page will refresh in default opencart , so where is that part of code located ? because I guess I could manually change it to new URL to make it work ?

New member

Posts

Joined
Tue Dec 09, 2014 5:21 am

Post by imdevlper18 » Sat Jun 03, 2017 8:06 pm

I have answered this question here:
viewtopic.php?f=191&t=183622#p672322

You need to change your shopping cart link in common.js file.
And it shall be fixed. You can read above topic.

Opencart Extensions | Professional opencart support | Support Ticket | support@cartbinder.com


User avatar
Active Member

Posts

Joined
Sun May 11, 2014 2:04 pm

Post by qtwrk » Mon Jun 05, 2017 3:43 am

imdevlper18 wrote:
Sat Jun 03, 2017 8:06 pm
I have answered this question here:
viewtopic.php?f=191&t=183622#p672322

You need to change your shopping cart link in common.js file.
And it shall be fixed. You can read above topic.
thanks for the help

just tried , and it didn't work.

I changed the line you mentioned in that thread , into this

Code: Select all

if (($(location).attr('pathname') == '/checkout-cart.html') || ($(location).attr('pathname') == '/checkout-processing.html')) {
	location = $(location).attr('href');
}
but unfortunately nothing happens ...

New member

Posts

Joined
Tue Dec 09, 2014 5:21 am

Post by qtwrk » Mon Jun 05, 2017 3:47 am

the code you mentioned there

Code: Select all

(function($) {
	var originalRemove = cart.remove;
    
	cart.remove = function(product_id) {
		$.ajax(originalRemove(product_id)).done(function() {
			cart_url = "/cart";
			checkout_url = "/checkout";

			if (!getURLVar('route') && ((cart_url && (($(location).attr('pathname') == cart_url) || ($(location).attr('pathname') == cart_url + "/"))) || (checkout_url && (($(location).attr('pathname') == checkout_url) || ($(location).attr('pathname') == checkout_url + "/"))))) {
				location = $(location).attr('href');
			}
		});
	};
})(jQuery);
should I replace it from

Code: Select all

if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
?

New member

Posts

Joined
Tue Dec 09, 2014 5:21 am

Post by thekrotek » Mon Jun 05, 2017 6:24 am

qtwrk wrote:
Mon Jun 05, 2017 3:43 am
but unfortunately nothing happens ...
You keep failing, because you blindly copy the code without even trying to understand it. If you want to do coding yourself, you at least should learn the basics of debugging. So wrap location['href'] or location['pathname'] in alert() and see the actual value of these variables on cart and checkout pages, instead of constantly putting something you think is right.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by imdevlper18 » Mon Jun 05, 2017 2:40 pm

Krotek is correct. When you are copying a code, just try to read little so you can do it correct.

See the code below:

Code: Select all

if ($(location).attr('href') == 'Your shopping cart url' || $(location).attr('href') == 'Your checkout url') {
Here can you see "Your shopping cart url". In this add your shopping cart url. So it shall be:

Code: Select all

if ($(location).attr('href') == 'https://www.store.com/cart' || $(location).attr('href') == 'https://www.store.com/checkout) {
You can see above i added example store url in place of "Your shopping cart url". Kindly add your store url here.
Hope this helps. You can also do this based on krotek answer i.e via pathname.

Opencart Extensions | Professional opencart support | Support Ticket | support@cartbinder.com


User avatar
Active Member

Posts

Joined
Sun May 11, 2014 2:04 pm

Post by qtwrk » Tue Jun 06, 2017 6:04 am

sorry for my stupidity , I don't really understand the PHP nor HTML , as matter of fact I don't even speak very well English...
but I did read through that post...

I tried that

Code: Select all

if (($(location).attr('pathname') == '/checkout-cart.html') || ($(location).attr('pathname') == '/checkout-processing.html')) {
and

Code: Select all

if ($(location).attr('href') == 'https://xxx/checkout-cart.html' || $(location).attr('href') == 'https://xxx/checkout-processing.html') {
but .... both of them failed...

I also clicked "refresh" button in extension page.

but one thing I do noticed and which is weird is that, even I disabled SEO URL and with modified common.js file , the default route index.php?route=checkout/cart still works

so can I assume somehow , the change I did in common.js didn't affect anything ?

New member

Posts

Joined
Tue Dec 09, 2014 5:21 am

User avatar
Active Member

Posts

Joined
Sun May 11, 2014 2:04 pm

Post by qtwrk » Thu Jun 08, 2017 6:35 am

imdevlper18 wrote:
Tue Jun 06, 2017 5:53 pm
Hi,

Your store url ?
Hi , I've PM'ed you the URL.
and suddenly something comes to my mind , I have Cloudflare , maybe the cached JS in Cloudflare is what causing me the problem for common.js doesn't have affect , I'm gonna try it again and see how it goes.

New member

Posts

Joined
Tue Dec 09, 2014 5:21 am

Post by qtwrk » Thu Jun 08, 2017 6:52 am

Hi , sorry again , for my stupidity

problem is solved.

I posted here in case someone got same problem as I did.

prior to the code mentioned before,

this line of code

Code: Select all

location = 'index.php?route=checkout/cart';
just under the line mentioned in early of the thread

Code: Select all

if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
should also be changed into new URL.

otherwise , the new URL will turn back to old URL and stop working.
for example , new URL is http://xxx/cart.html
the first click on remove will refresh the page into http://xxx/index.php?route=checkout/cart and then second time to remove item will NOT refresh the page on its own.

and be aware of CACHE.

I also forgot to clear my browser cache alone with Cloudflare cache.

there is a good way to determinate if JS file is changed by access directly http://xxx/catalog/view/javascript/common.js to see the file is changed or not.

thanks for you help :)

New member

Posts

Joined
Tue Dec 09, 2014 5:21 am

Post by imdevlper18 » Thu Jun 08, 2017 1:45 pm

Great !!
Sometimes Cache is the main issue despite fixing things.
It is good to clear cache if using some cache software or cloudfare.

Opencart Extensions | Professional opencart support | Support Ticket | support@cartbinder.com


User avatar
Active Member

Posts

Joined
Sun May 11, 2014 2:04 pm

Post by qtwrk » Fri Jun 09, 2017 1:56 am

imdevlper18 wrote:
Thu Jun 08, 2017 1:45 pm
Great !!
Sometimes Cache is the main issue despite fixing things.
It is good to clear cache if using some cache software or cloudfare.
just wondering here , viewtopic.php?f=191&t=183622#p672322 this thread last post , there is seems a better approach

Code: Select all

(function($) {
	var originalRemove = cart.remove;
    
	cart.remove = function(product_id) {
		$.ajax(originalRemove(product_id)).done(function() {
			cart_url = "/cart";
			checkout_url = "/checkout";

			if (!getURLVar('route') && ((cart_url && (($(location).attr('pathname') == cart_url) || ($(location).attr('pathname') == cart_url + "/"))) || (checkout_url && (($(location).attr('pathname') == checkout_url) || ($(location).attr('pathname') == checkout_url + "/"))))) {
				location = $(location).attr('href');
			}
		});
	};
})(jQuery);
how am i to do that ? replace the line with it ?

Code: Select all

if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {

New member

Posts

Joined
Tue Dec 09, 2014 5:21 am
Who is online

Users browsing this forum: Amazon [Bot], darkhorse and 66 guests