Side cart dont work on cached page

I have a problem that the ajax side cart does not work in the latest version with the cache. The site is https://www.tilt.rs/

It correctly displays how many products are in the cart, but the entire sidebar is cached, it should load via ajax

Comments

  • Hi,

    Do you use a caching plugin for that?

    If yes, can you tell me the name of it, please?


    Thanks

  • I am using w3 total cache

  • Hey,

    Please send us WordPress dashboard access privately thru the contact form, which is on the right side at http://themeforest.net/user/muffingroup#contact, and we will check what might be the reason.

    Notice!

    Please attach a link to this forum discussion.

    Sending incorrect or incomplete data will result in a longer response time.

    Therefore, please ensure that the data you are sending is complete and correct.

    Thanks

  • I have adjusted some settings, please check it now.


    Best regards

  • It's still not solved. I saw you changed to basic caching, but its ususaly worse than advance. I have few licenses where I have the same problem on different server environment, it's not always been like that. Definitely the mini cart is updated via ajax fragment when a product is added to the cart, while when loading the page the mini cart is generated via php and only counter for product in basket work via ajax. Same problem is for the popup on top off navigation, when turned off on x it should stay off. I will investigate source code till Tuesday and I will contact you after, if you come up with something, let me know. Maybe this problem is for tier 3 or development, but I believe that one correct jQuery snippet can solve it. External mini cart plugin work well, but they don't fit into my design concept

  • Dear All,


    In the woocommerce.js file there is no update of the cart at all when the page is opened.

    If anyone needs this option, I made a fix.

    It would be good if developers pay attention to this.



    Copy/Paste this code in: Betheme -> Theme Options -> Custom CSS & JS -> JS


    ----------------------- code ------------------------------


    jQuery(function($) {

      var cartElement = $(".mfn-cart-holder");


      // Refreshing basket data based on new fragment

      function refreshCart(fragment) {

        var cartContent = fragment['div.widget_shopping_cart_content'];

        var cartCount = fragment['.header-cart-count'];

        var cartTotal = fragment['.header-cart-total'];


        // Updating cart information

        cartElement.find('.mfn-ch-content').html(cartContent);

        cartElement.find('.header-cart-count').replaceWith(cartCount);

        cartElement.find('.header-cart-total').replaceWith(cartTotal);


        $('.mfn-cart-holder').attr('aria-expanded', 'false');

      }


      // Sending an Ajax request to get a new fragment

      function getUpdatedCart() {

        $.ajax({

          type: 'POST',

          url: wc_add_to_cart_params.ajax_url,

          data: {

            action: 'woocommerce_add_to_cart',

            current_cart: $('.header-cart-count').first().text()

          },

          success: function(response) {

            if (response === 'error') {

              // Here you can process the error if there was a problem adding the product to the cart

              return;

            }


            $(document.body).trigger('refresh');



            refreshCart(response);

          }

        });

      }


      // Initiating cart updates on page load

      getUpdatedCart();


      $(document.body).on('refresh', function(e) {

        cart.refresh();

      });


      cart = {


        refresh: function() {

          $.ajax({

            url: mfnwoovars.ajaxurl,

            data: {

              'mfn-woo-nonce': mfnwoovars.wpnonce,

              action: 'mfnrefreshcart'

            },

            type: 'POST',

            cache: false,

            success: function(response) {

              $('.mfn-cart-holder .mfn-ch-content').html(response.content);

              $('.mfn-cart-holder .mfn-ch-footer .mfn-ch-footer-totals').html(response.footer);

              $('.mfn-cart-holder').removeClass('loading');


              // side cart buttons

              $('.mfn-ch-footer-buttons').show();

              return;

            }

          });

        }

      }


    });

  • Good to see that you found a workaround.

    I have passed this to the dev team, and we will take a look at this.


    Best regards

  • We have prepared a solution for that.

    Please send us WordPress dashboard access privately thru the contact form, which is on the right side at http://themeforest.net/user/muffingroup#contact and we can implement it on your website.

    Notice!

    Please attach a link to this forum discussion.

    Sending incorrect or incomplete data will result in a longer response time.

    Therefore, please ensure that the data you send are complete and correct.

    Thanks

  • Could you guys please give a PUBLIC solution for this. I just had to add this great code as a workaround from andone. I use BerqWP cache plugin. Before ive added the code, the cart wouldn´t load, or show up or whatever. I´ve added the code, now it seems that it works how it should work. But this should be really a standard feature of your theme.

  • Hey @Nachbarsaft

    Please send us the WordPress dashboard and FTP access privately through the contact form, which is on the right side at https://themeforest.net/user/muffingroup#contact and we will check that.

    Notice!

    Please attach a link to this forum discussion.

    Sending incorrect or incomplete data will result in a longer response time.

    Therefore, please ensure that the data you send are complete and correct.

    Thanks

Sign In or Register to comment.
This website uses cookies

We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners who may combine it with other information that you’ve provided to them or that they’ve collected from your use of their services.

Cookies are small text files that can be used by websites to make a user's experience more efficient.

The law states that we can store cookies on your device if they are strictly necessary for the operation of this site. For all other types of cookies we need your permission. This means that cookies which are categorized as necessary, are processed based on GDPR Art. 6 (1) (f). All other cookies, meaning those from the categories preferences and marketing, are processed based on GDPR Art. 6 (1) (a) GDPR.

This site uses different types of cookies. Some cookies are placed by third party services that appear on our pages.

You can at any time change or withdraw your consent from the Cookie Declaration on our website.

Learn more about who we are, how you can contact us and how we process personal data in our Privacy Policy.

Please state your consent ID and date when you contact us regarding your consent.