Page 1 of 1

Cart not refreshing after deleting or adding product

Posted: Mon Jul 24, 2017 10:14 pm
by gunnysack263
My cart is caching prior information and I can't get it to refresh to the current items in the cart.

Example:
Item A added to cart - Item A Shows up in cart at the top of the page correctly.
Item B added to cart - Cart total is correct and shows two items. Click on cart button and only Item A shows up with the total of only item A.
Click Refresh Page - Both Items A & B show up with correct total.
Click Cart button at top and delete Item A - Cart at top of page shows one item and correct amount.
Click cart button at top - Cart shows both Items A & B.
Click Refresh button - Cart shows only item B

It seems to be either an ajax issue or a caching issue, but I can't figure it out and can not find help online for OpenCart Version 3.0.1.1.

Thank you!

Re: Cart not refreshing after deleting or adding product

Posted: Tue Jul 25, 2017 9:37 pm
by labeshops
You should add this to the bug reports section. I confirm the same thing is happening in v3.0.2.0

It is also occurring when you view cart from the mini cart - it only showed 1 product in the cart until I refreshed the page when the second suddenly appeared.

Re: Cart not refreshing after deleting or adding product

Posted: Mon Mar 05, 2018 4:59 pm
by vaughnchill
Was there ever a fix for this? I am having a similar issue. I don't remember this being an issue when I first downloaded 3.0.2, so not sure if I did something wrong.

Re: Cart not refreshing after deleting or adding product

Posted: Sat May 05, 2018 5:38 pm
by cosmicx
UPDATE: Problem Fixed!

The fix:
I did another clean install of OpenCart 3.0.2.0 and imported my database dump and voila!

I'm thinking maybe the previous version I downloaded was a different build than the lated I used.
---------------------------------
This might be an OpenCart bug?

I've been working to find the culprit, at first I though it was the Journal Theme causing the issue. I contacted their support and told them the issue, along with videos and necessary issue reporting. But even after setting the Default Theme of OpenCart, same issue occurs.

Issues:
1. Adding products does not update/refresh the mini cart. The part which shows the product image, sub-total and total.
2. Removing products by clicking on the 'x' button does not update/refresh the mini cart. To remove them, remove products one by one, by clicking x button then reload the page, then do the same for the rest of the products.


My Setup:
- OpenCart 3.0.2.0 - downloaded from OpenCart.com
- VPS running Ubuntu 16.04, PHP7.0, VestaCP Control Panel
- storage/ directory is outside of public_html
- Multi-store setup, sub-domain for each multi-store.

What I've tried:

- Did another setup on the same VPS, but different domain name, and single store setup only.
- Installed Journal Theme and Imported a demo.
- Mini cart works fine as it should

Re: Cart not refreshing after deleting or adding product

Posted: Mon May 07, 2018 7:59 am
by IP_CAM
Well, this Extension could possibly solve this problem.
Ernie
---
Notice of addition
Displays a notice about adding goods to the cart, wishlist, compare.
https://www.opencart.com/index.php?rout ... n_id=32459
---
Image
---

Re: Cart not refreshing after deleting or adding product

Posted: Sat Jul 28, 2018 2:31 am
by Fabienlolo
Hi, i downloaded OC 3.0.2. few days ago, and i have this issue as well. I opened a new topic. I guess i am not good at finding topics, because i just find yours now.
Unfortunately, no solutions for me right now. viewtopic.php?f=202&t=205891#top
I found this https://github.com/opencart/opencart/issues/2980 for another version, but may be that means, that there should be some server requierements that are not metionned.
Any way, 3.0.2 dowloaded on the 24/07/18 still have this issue for me.

Re: Cart not refreshing after deleting or adding product

Posted: Wed Aug 01, 2018 2:49 am
by theitwebcare
Very strange cart and checkout does't refreshing after deleting or adding product or update qty. need to full reload page ctrl+f5

I am same issue Opencart Version 3.0.2.0 Journal 2.16.2.

when change add to cart qty or delete product from cart page don't update.... I have to hard reload or ctrl+f5 many times then after it get updated pages.

NO CACHING ACTIVE , OPENCART CACHE DISABLE , JOURNAL CACHE DISABLE , SERVER CACHE DISABLE .HTACCESS CACHE DISABLE. ALL DISABLED

any one have solution ? path please reply thx in advance.

Re: Cart not refreshing after deleting or adding product

Posted: Thu Aug 02, 2018 6:50 am
by Fabienlolo
Hi, thank for your concern.
I made it. Problem fixed, because of my web hosting guy. He did not explained what he did exactly, but since this guy came into play the whole updating cart/coupons/payment methods and other stuff, is updating just the right way.
Here is my original post. viewtopic.php?f=202&t=205891
as soon as i have an explanation, i will post it in that topic because this is the one i opened.
Thanks again for your attention.

Re: Cart not refreshing after deleting or adding product

Posted: Sun Sep 16, 2018 7:44 pm
by nationalpc
Hi,
I am also facing the same issue. I have tried a lot, My hosting (Hostgator Cloud) support replied that, it's a bug from Opencart !!

What to do now ??

Re: Cart not refreshing after deleting or adding product

Posted: Mon Sep 17, 2018 12:32 am
by daniGo
Try replace in catalog/view/javascript/common.js

in add function

Code: Select all

if (json['success']) {
	$('#content').parent().before('<div class="alert alert-success"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div>');

	// Need to set timeout otherwise it wont update the total
	setTimeout(function () {
		$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
	}, 100);

	$('html, body').animate({ scrollTop: 0 }, 'slow');

	$('#cart > ul').load('index.php?route=common/cart/info ul li');
}
with

Code: Select all

if (json['success']) {
    $.ajax({
        url: 'index.php?route=common/cart/info',
        dataType: 'html',
        cache: false,
        success: function(html) {
            $('#cart > ul').html($(html).find('#cart > ul').html());
        },
	error: function(xhr, ajaxOptions, thrownError) {
		alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
        }
    }).done(function() {
        $('#content').parent().before('<div class="alert alert-success"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div>');

        $('html, body').animate({ scrollTop: 0 }, 'slow');

        $('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
    });
}
edit function

Code: Select all

// Need to set timeout otherwise it wont update the total
setTimeout(function () {
	$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
}, 100);

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');
}
with

Code: Select all

if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
    location = 'index.php?route=checkout/cart';
} else {
    $.ajax({
        url: 'index.php?route=common/cart/info',
        dataType: 'html',
        cache: false,
        success: function(html) {
            $('#cart > ul').html($(html).find('#cart > ul').html());
        },
        error: function(xhr, ajaxOptions, thrownError) {
            alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
        }
    }).done(function() {
        $('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
    });
}
remove function

Code: Select all

// Need to set timeout otherwise it wont update the total
setTimeout(function () {
    $('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
}, 100);

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');
}
with

Code: Select all

if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
    location = 'index.php?route=checkout/cart';
} else {
    $.ajax({
        url: 'index.php?route=common/cart/info',
        dataType: 'html',
        cache: false,
        success: function(html) {
            $('#cart > ul').html($(html).find('#cart > ul').html());
        },
        error: function(xhr, ajaxOptions, thrownError) {
            alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
        }
    }).done(function() {
        $('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');
    });
}

Re: Cart not refreshing after deleting or adding product

Posted: Mon Sep 17, 2018 2:26 am
by Lavingstar
I've tried it right now, but in my case it did not change anything unfortunately ... :-\

Re: Cart not refreshing after deleting or adding product

Posted: Thu Sep 20, 2018 9:56 pm
by nationalpc
I am facing the same issue in my Hostgator cloud business server. Hostgator support team is claiming that, it's a opencart issue. They did not find any error in the log file. That's why they are unable to solve this issue.

Re: Cart not refreshing after deleting or adding product

Posted: Fri Sep 21, 2018 3:01 am
by IP_CAM
Well, I just run into a similar Problem again, by testing some of YOOCART's free
v.2.x Bootstrap Themes, and yoohan-2031 + yoobeat-2031 worked,
but the yoobento-2302 Theme makes use of the $product['cart_id']
Variable, wich prevented, in my Case and OC-Version, products to be removed
from the header CART again.

So, make sure, if you use any Custom Theme, that this $product[' xxx '] Variable
meets your OC Version 'standard', to so at least solve one potential problem, related
with this. But I also could not yet find out, why it shows Products in this Cart, but it
still only tells you, that the cart is empty, if clicked on, in some test installs at
least... :choke:

Please note: The Image only displays the Value, not working in MY OC Version, so,
check in your own OC Version, wich one needs to exist, before changing anything.
or then, just REMOVE the cart.tpl file from the Custom Theme, then, the default
Theme .../template/common/cart.tpl File automatically will be used instead!
Just in case, but DON't do it with Journal - Pavo - and other heavy loaded Theme
Extensions, they are built differently, and may no longer function after such ! ;)
Ernie
---
It now works! :D (PEKU's OC-2.0.3.1 Theme enhanced OC v.1.5.6.5 EDGE used)
http://www.ipcam.li/shop/en/Components/ ... 25c28.html
---
Image

Re: Cart not refreshing after deleting or adding product

Posted: Mon Sep 24, 2018 12:44 pm
by IP_CAM
Good News, I found my Problem, after all. And I recall, to have been
wondering about the Fact, that the cart.tpl file has been moved from
the Theme module/... Directory to the Theme common/...
Directory from OC v.2 up.

But I forgot about this, up to now, by finding out, that a few of my OC-2 Custom
Themes only 'Header-Cart-autoupdate-function' as planned, if I let OC use
the default Theme product.tpl file instead, by simply removing the Custom
Theme product.tpl, on my latest Multitheme Test Site:
http://www.ejacob.ch/shop/index.php
---
It might at least be of some help for those, mixing 1.5.6.x Version Source with later
Version responsive Themes ! :D But if one has a working (default) Theme, and only
problems with Custom Themes on this, just either remove the Custom Theme product.tpl,
or replace it with the working Theme product.tpl file, to probably make it work.
Ernie
---
Image