Home › Forums › WoodMart support forum › bug with cart icon after update 6.0.2
bug with cart icon after update 6.0.2
- This topic has 22 replies, 2 voices, and was last updated 3 years, 7 months ago by Artem Temos.
-
AuthorPosts
-
April 10, 2021 at 11:29 pm #281467
steph_inventParticipantHello,
After updating to the latest version, I have noticed a bug with the cart icon:
1. I have added a product to the cart, the product has a price of 400€
2. I have deleted then this product from the cart, so the cart is now empty
3. When I surf from one page to another, I notice that the cart icon change, it shows for a fraction of second the old amount: 400€ and shows 1 product and then disappear quickly and hows again 0.Would you please look into that in order to not to allow to show again something that has been already deleted from the cart
Thank you
RegardsApril 11, 2021 at 10:37 am #281566
steph_inventParticipantHello,
Please find in the private area two examples of what is happening.
Thank
RegardsApril 12, 2021 at 6:55 am #281726
Artem TemosKeymasterHello,
It works in this way if you are using some kind of page cache like WP Rocket. The cart widget is cached and updated with AJAX on every page load.
Kind Regards
April 12, 2021 at 12:01 pm #281895
steph_inventParticipantHello,
Thank you for your reply.
I have noticed the same thing on your demo version, but this should not be normal. you agree?
Yes I am using WP rocket. Do you think that I have to exclude the cart cookie: woocommerce_items_in_cart ?
Thank you
RegardsApril 12, 2021 at 1:43 pm #281956
Artem TemosKeymasterYes, it is how it works on our demo and on all other WooCommerce websites that have some kind of cache like WP Rocket.
April 12, 2021 at 5:44 pm #282072
steph_inventParticipantI recommand you then to add the cookie ID “woocommerce_items_in_cart” in the advanced settings of WP rocket. This will solve the problem 😉
April 13, 2021 at 7:28 am #282192
Artem TemosKeymasterHave you solved this issue on your side? Could you please send us a link where we can test this?
April 13, 2021 at 10:46 am #282308
steph_inventParticipantHello,
Yes I have solve it on my end.
I have added the cookie ID “woocommerce_items_in_cart” in the advanced settings of WP rocket and it works now.
You can check it on the link that I have sent you in the private area, you can add products to the cart and surf on the website, you will see that the cart will not flash anymore 😉
Regards
April 13, 2021 at 11:32 am #282330
Artem TemosKeymasterHello,
As I can see, this page is not cached at all. Looks like the WP Rocket is completely disabled there.
Kind Regards
April 13, 2021 at 12:08 pm #282349
steph_inventParticipantHello,
In fact I have disabled all the plugins that you can check the other problems I have asked for (filter problem etc) but I just re enabled everything so it should be fine now. Please check the URL below
You need to add a product and then surf in the whole website and you will see that the cart will not flash as before.
Regards
April 13, 2021 at 1:20 pm #282384
Artem TemosKeymasterHello,
We still don’t see that the WP Rocket is activated. So the pages are not cached yet.
Kind Regards
April 13, 2021 at 3:03 pm #282436
steph_inventParticipantHello
I confirm you that WP rocket is running correctly (cf. screenshots)
Open the browser’s source view of the page and scroll to the bottom. At the very end you will see an entry like this as I show on the screenshot and which confirm that the caching is working fine: <!– This website is like a Rocket, isn’t it? Performance optimized by WP Rocket. Learn more: https://wp-rocket.me – Debug: *********–>
And Wappalyzer confirms that WP rocket is working and caching my website
Regards
April 14, 2021 at 6:14 am #282578
Artem TemosKeymasterHello,
When we add something to the cart, we don’t see this WP Rocket comment at the end of the page https://gyazo.com/a2dd714580c443d5324b81ae4679b92f
Kind Regards
April 14, 2021 at 5:24 pm #282911
steph_inventParticipantHello,
You are totally right, I have noticed this too. The pages using this cookie are not longer cached when I add something to the cart.
“WP Rocket answered me regarding this issue and told me that Menu Cart may not be fully “AJAX-ified”.
Using AJAX for cart widgets is required in order for them to be compatible with the page caching — you can’t rely on PHP to update it, because WP Rocket eliminates all PHP/MySQL processes from a page and creates static HTML output instead (as do most other caching plugins).
Ideally, content would be updated dynamically by using the AJAX method. Although some themes/widgets/plugins/ use PHP code instead. PHP doesn’t run on cached pages and therefore the content is being cached.”
Are you intending to update the cart using Ajax instead of PHP code? This will help you and help us to avoid this flash problem.
Thank you
RegardsApril 14, 2021 at 5:56 pm #282913
steph_inventParticipantHello
To complete my previous message, here are some useful links that has been given to me by WP Rocket. I believe that I can use the JS in your theme? Can you help me to adapt the code and tell me what code should I use to solve this issue? This might be interesting for your theme.
“AJAX-ify” your cart widget.
The specifics will vary depending on your theme/plugin, but the concept is described in these posts:
• https://wp-rocket.me/blog/using-woocommerce-dynamic-cart-wp-rocket/
• http://docs.woothemes.com/document/show-cart-contents-total/Thanks
RegardsApril 15, 2021 at 7:01 am #283068
Artem TemosKeymasterHello,
Yes, that’s exactly how it works at the moment. It updates the cart widget with AJAX on page load. And it is a WooCommerce default functionality. That is why you see this “flash” of the cached widget first, and then it is updated to the actual state.
Kind Regards
April 20, 2021 at 9:16 pm #284799
steph_inventParticipantHello,
Thank you for your reply.
I’ve been digging into the theme code and it seems the Cart is not fully “ajaxified”.
The cart seems to work like this:
– When the HTML is loaded, the cart value is printed in the HTML,
<span class=”wd-cart-subtotal<?php echo woodmart_get_old_classes( ‘ woodmart-cart-subtotal’ ); ?>”><?php echo WC()->cart->get_cart_subtotal(); ?></span>it happens at this file:
/wp-content/themes/woodmart/inc/integrations/woocommerce/template-tags.phpSo, if the cache is cleared and there are elements in the cart, the cart value will be loaded from that user, and saved into the cache.
This value will be hardcoded into the HTML.
Then, when the page is loaded, the cart is also updated using AJAX, and that’s what causes the flash with the wrong value.
Therefore, the problem is related to the theme. Can you ensure please that the Minicart is properly ajaxified in order to avoid this problem?
A workaround would be to tweak this code a bit, and display an empty value instead. It can be easily achieved by modifying this part: <?php echo WC()->cart->get_cart_subtotal(); ?>
But I don’t know if that could break other functionality, so I need your support about it.Moreover, this can be useful for everyone and it is a good evolution that you can do on your theme.
Thank you
RegardsApril 21, 2021 at 6:27 am #284915
Artem TemosKeymasterHello,
Could you please check how it works with a default WordPress theme WooCommerce Storefront to understand is it our theme issue or not? It has the same widget in the header.
As we said, this widget is based on WooCommerce standard function. And it is the way it works with any other WordPress theme.Regards
April 23, 2021 at 10:48 pm #286120
steph_inventParticipantHello,
Thank you for your reply.
It works fine on default woocommerce theme!
Would you please ask your developers to look at what I have gave you above as details
When the HTML is loaded, the cart value is printed in the HTML,
<span class=”wd-cart-subtotal<?php echo woodmart_get_old_classes( ‘ woodmart-cart-subtotal’ ); ?>”><?php echo WC()->cart->get_cart_subtotal(); ?></span>it happens at this file:
/wp-content/themes/woodmart/inc/integrations/woocommerce/template-tags.phpSo, if the cache is cleared and there are elements in the cart, the cart value will be loaded from that user, and saved into the cache.
This value will be hardcoded into the HTML.
Then, when the page is loaded, the cart is also updated using AJAX, and that’s what causes the flash with the wrong value.
Therefore, the problem is related to the theme. Can you ensure please that the Minicart is properly ajaxified in order to avoid this problem?
Thank you
Regards
April 24, 2021 at 9:04 am #286179
Artem TemosKeymasterHello,
Please, send us a screenshot of how it works with the default theme. Note that the value is printed in the code by WooCommerce (our theme uses its code).
Kind Regards
April 24, 2021 at 6:39 pm #286293
steph_inventParticipantHello,
Here is a screenshot of how it works on default woocomerce theme Storefront: http://somup.com/crfZFaFrtv
As you can see, the cart is not flashing anymore!
It is a problem related to the theme and you can see it in the code used below.Please take a look again on the message that I have sent previously and consult your development team in order to ajaxify the cart
The cart seems to work like this:
– When the HTML is loaded, the cart value is printed in the HTML,
<span class=”wd-cart-subtotal<?php echo woodmart_get_old_classes( ‘ woodmart-cart-subtotal’ ); ?>”><?php echo WC()->cart->get_cart_subtotal(); ?></span>it happens at this file:
/wp-content/themes/woodmart/inc/integrations/woocommerce/template-tags.phpSo, if the cache is cleared and there are elements in the cart, the cart value will be loaded from that user, and saved into the cache.
This value will be hardcoded into the HTML.
Then, when the page is loaded, the cart is also updated using AJAX, and that’s what causes the flash with the wrong value.
Therefore, the problem is related to the theme. Can you ensure please that the Minicart is properly ajaxified in order to avoid this problem?
A workaround would be to tweak this code a bit, and display an empty value instead. It can be easily achieved by modifying this part: <?php echo WC()->cart->get_cart_subtotal(); ?>
But I don’t know if that could break other functionality, so I need your support about it.April 26, 2021 at 6:19 am #286551
Artem TemosKeymasterIt works in exactly the same way but the page is loaded much faster with storefront and you don’t see this problem. If you have the same light page with WoodMart you will see the same. Also, check the source code with a default theme. You will see that the value is hardcoded there as well.
Also, switch to the default theme on your website so we can check it ourselves.April 26, 2021 at 6:26 am #286555
Artem TemosKeymasterAlso, as for the code you referred to, you can check the official WooCommerce source and find the same mechanism in their default cart widget https://github.com/woocommerce/woocommerce/blob/b19500728b4b292562afb65eb3a0c0f50d5859de/includes/wc-template-functions.php#L2147
The same code is used by Storefront. -
AuthorPosts
- You must be logged in to create new topics. Login / Register