Post by ianhaney » Sun Apr 23, 2017 7:51 pm

Hi

I have noticed a bug on my shopping cart page, when adding a product to the shopping cart, I click on the X to remove it but it does not remove it from the page, it removes it from the mini cart in the header but not on the actual page, I am using opencart 2.0.3.1. Has anyone had this issue before or got a solution.

The URL is https://www.broadwaymediadesigns.co.uk/store/ - add any product and try and remove it on the page and will see the issue

UPDATE: I have SEO URL'S enabled and looking on Google it could be to do with the SEO URL's feature being on and that is the issue, I'll keep looking and post a solution if manage to find one

Thank you in advance

Active Member

Posts

Joined
Sun Jun 24, 2012 2:30 am

Post by imdevlper18 » Wed Apr 26, 2017 4:05 pm

Its not a bug but because you have added seo keyword to your cart and checkout page.
The refresh has stopped on above pages. Before seo keyword entered there must be refresh happening when you changed anything on this page.
You need to edit common.js file of your theme for this fix.

For default theme its present on this path:

Code: Select all

catalog/view/javascript/common.js
If using custom theme you shall need to edit your common.js file which has below code in it.

In this file, look for this line:

Code: Select all

if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
The above line says that if its checkout/cart or checkout/checkout page then do the refresh.
But after your seo keyword entry this urls have changed.

So you add this line instead of above line:

Code: Select all

if ($(location).attr('href') == 'Your shopping cart url' || $(location).attr('href') == 'Your checkout url') {
With this change it shall now refresh the page.
For more help contact directly via email: support@cartbinder.com

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 ianhaney » Wed Apr 26, 2017 5:05 pm

Hi

I have done the change in the two common.js files as had one in the theme js folder as well but is still not refreshing

below is the coding I have

this is what it was

Code: Select all

if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
I changed it to below

Code: Select all

if ($(location).attr('href') == 'cart' || $(location).attr('href') == 'checkout/checkout') {
the original code was appearing three times so changed it 3 times

I will email you now or you on skype?

Active Member

Posts

Joined
Sun Jun 24, 2012 2:30 am

Post by thekrotek » Sat Jun 03, 2017 11:37 pm

ianhaney wrote:
Wed Apr 26, 2017 5:05 pm
I have done the change in the two common.js files as had one in the theme js folder as well but is still not refreshing
It's not working, because $(location).attr('href') is a FULL URL, not just part of it. And you only put "cart". Should be something like "http://yourstore.com/cart".

If you want to use only part of the URL without domain, use "pathname" instead of "href". Here's a better code for this:

Code: Select all

if (($(location).attr('pathname') == '/cart') || ($(location).attr('pathname') == '/checkout')) {
	location = $(location).attr('href');
}
But the best approach is to expand "update" and "remove" functions like this:

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);
First this code takes original cart.remove() function, wraps it in ajax() function, calls it, waits for function to complete and only then reloads the page, if necessary. To avoid multiple reloads it checks for lack of "route" variable in URL. Plus I've added a check for URL with trailing slash.

It should work with all themes, not just with default one, since this code allows original function to do its job.

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


User avatar
Expert Member
Online

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by legitdev » Thu Mar 14, 2019 9:55 pm

Hi, please see the attached two screenshot image.
When I click on "Buy Now" bottom, it will add it to the Shopping Cart, but when I click "Continue Shopping" I don't see a "View Cart" on the Top Menu or the site or anywhere. Please help with this issue as soon as you can. I have version 2.2.0.0

Thank you

Attachments

cart_2.PNG

cart_2.PNG (36.04 KiB) Viewed 804 times

cart_1.PNG

.When I click "Continue Shopping" I don't see a "View Cart" on the Top Menu or anywhere - cart_1.PNG (154.55 KiB) Viewed 804 times


Newbie

Posts

Joined
Wed Apr 25, 2018 9:55 am
Who is online

Users browsing this forum: No registered users and 7 guests