Home Forums WoodMart support forum bug with cart icon after update 6.0.2

bug with cart icon after update 6.0.2

Viewing 23 posts - 1 through 23 (of 23 total)
  • Author
    Posts
  • #281467

    steph_invent
    Participant

    Hello,

    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
    Regards

    #281566

    steph_invent
    Participant

    Hello,

    Please find in the private area two examples of what is happening.

    Thank
    Regards

    #281726

    Artem Temos
    Keymaster

    Hello,

    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

    #281895

    steph_invent
    Participant

    Hello,

    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
    Regards

    #281956

    Artem Temos
    Keymaster

    Yes, it is how it works on our demo and on all other WooCommerce websites that have some kind of cache like WP Rocket.

    #282072

    steph_invent
    Participant

    I recommand you then to add the cookie ID “woocommerce_items_in_cart” in the advanced settings of WP rocket. This will solve the problem 😉

    #282192

    Artem Temos
    Keymaster

    Have you solved this issue on your side? Could you please send us a link where we can test this?

    #282308

    steph_invent
    Participant

    Hello,

    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

    #282330

    Artem Temos
    Keymaster

    Hello,

    As I can see, this page is not cached at all. Looks like the WP Rocket is completely disabled there.

    Kind Regards

    #282349

    steph_invent
    Participant

    Hello,

    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

    #282384

    Artem Temos
    Keymaster

    Hello,

    We still don’t see that the WP Rocket is activated. So the pages are not cached yet.

    Kind Regards

    #282436

    steph_invent
    Participant

    Hello

    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

    #282578

    Artem Temos
    Keymaster

    Hello,

    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

    #282911

    steph_invent
    Participant

    Hello,

    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
    Regards

    #282913

    steph_invent
    Participant

    Hello

    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
    Regards

    #283068

    Artem Temos
    Keymaster

    Hello,

    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

    #284799

    steph_invent
    Participant

    Hello,

    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.php

    So, 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
    Regards

    #284915

    Artem Temos
    Keymaster

    Hello,

    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

    #286120

    steph_invent
    Participant

    Hello,

    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.php

    So, 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

    #286179

    Artem Temos
    Keymaster

    Hello,

    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

    #286293

    steph_invent
    Participant

    Hello,

    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.php

    So, 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.

    #286551

    Artem Temos
    Keymaster

    It 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.

    #286555

    Artem Temos
    Keymaster

    Also, 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.

Viewing 23 posts - 1 through 23 (of 23 total)