Support » Plugin: WooCommerce Menu Cart » Not appearing on first item

  • Resolved tarkan

    (@tarkan)


    Hi,

    This was working fine in 2.6.1, but since we updated to 2.7.0. When adding the first item to cart – the menu cart does not appear.

    Adding a second item makes the menu cart appear – showing 2 items (correctly).

Viewing 12 replies - 16 through 27 (of 27 total)
  • Hmmm… What for a timeout do you mean?

    In the networktools of firefox I can see the post request to the “https://elkantera.com/?wc-ajax=add_to_cart” page, and the response takes round about 600 ms and I get the json Object as response.

    Or do you mean something else?
    Or maybe you was a little but unlucky and the server was really slow at your try.

    That means, I get the Json oject with the values for the menu cart Icon, (the ajax works?), but the menu cart icon don`t refreshes?

    Sorry, for my hunderd questions. But I try to understand, because I cann ask at the woocommerce Foum the right question. =)

    • This reply was modified 3 years, 6 months ago by frischi.
    • This reply was modified 3 years, 6 months ago by frischi.
    • This reply was modified 3 years, 6 months ago by frischi.
    • This reply was modified 3 years, 6 months ago by frischi.
    Plugin Author Ewout

    (@pomegranate)

    I guess the site was indeed just very slow at the moment I tried. I tried again and was able to succesfully add something to the cart. And you’re correct, the fragments are properly returned but the WooCommerce scripts are not updating them accordingly. Could you try to temporarily add the “Cart” widget to your sidebar to check if that works properly? That is updated using the same scripts so if that works but menu cart doesn’t, it helps to narrow down the issue.

    Ok, I tried the Sidebar-widget and it works perfectly with or without the custom ajax even if I`m logged or logged in.

    Something else is never working in the menu cart icon: When I delete some articles in the cart or change the amount of the articles, nothing happens in the cart icon.

    Plugin Author Ewout

    (@pomegranate)

    Very strange… I’m afraid we’ve come at a bit of a dead-end regarding this, I think this is a theme compatibility issue of some sorts. If you want to confirm this by temporarily switching to a different theme that may help. AFAIK the issue from the OP should be resolved with this update, as this didn’t necessarily have to do with the AJAX update itself but with the “Always show cart” option disabled (before the fix the menu cart HTML would update on the site but was still hidden).
    Your case is different because the AJAX replacements by WooCommerce do not apply to the menu at all!

    The fact that it works for the menu cart when you’re logged in is even more confusing, usually that points to an issue related to server side caching (logged in users are mostly excluded from caching), but in your case the AJAX response seems to contain the correct (uncached) HTML for the menu. It’s a bit tricky because the actual replacement is done by WooCommerce itself, we just pass the updated HTML…

    I’m sorry I don’t have a solution for you at this point!

    @tarkan, can you confirm the issue is resolved?

    Thread Starter tarkan

    (@tarkan)

    @pomegranate Yes the changes work fine for us!!

    Ok, I tried it out with twentysixteen and twentyseventeen in shop page. The ajax is working there if the custom ajax is off and the woocommerce ajax is on. So thanx for yout help and I will try my luck at the theme developer.

    @pomegranate

    I try to find out the problem with my theme and the ajax refresh of the menu icon. But I can`t found the place in your code, where javascript refreshes the link in the menu, if the cart has updated. I found it for the custom ajax of menu cart plugin. But where can I found it, if the custom ajax is disabled. With disabled custom ajax the ajax refresh works in all themes except mine.

    Is it javascript from woocommerce? But how do they know which html node they have to refresh?

    I found the filter_nav_menus() function which uses add_filter( ‘wp_nav_menu_’ . $this->options[‘menu_slugs’][1] . ‘_items’, array( &$this, ‘add_itemcart_to_menu’ ) , 10, 2 );

    But this is only for a complete refresh of the site, isn´t it?

    Plugin Author Ewout

    (@pomegranate)

    Hi!
    The AJAX refreshments are entirely handled by WooCommerce core functions, by something called “cart fragments”:
    https://github.com/woocommerce/woocommerce/blob/3.4.0/assets/js/frontend/cart-fragments.js

    This replaces parts of the page by a selector, as defined by our plugin here:
    https://github.com/wpovernight/wp-menu-cart/blob/master/wp-menu-cart.php#L490

    The code you refer to is indeed only for page refresh (and doesn’t always work if you have server side caching enabled on your site by a plugin like WP Super Cache, WP Rocket, W3TC or the likes), hence the AJAX addition which resolves that potential issue.

    Plugin Author Ewout

    (@pomegranate)

    @pomegranate
    Hi, I’m having a similar problem. When I add a product to the cart, the cart is not upgrading. Even if I add a second product the cart doesn’t change. The only way is to click on the cart and the page reload with the right cart value. Can you help me please?
    The website is: https://capsule-compatibili.it/
    Thanks! Regards,
    piermal

    Plugin Author Ewout

    (@pomegranate)

    Hello Piermal,
    Your error is unrelated and caused by something in the WooCommerce core scripts during the add-to-cart action:

    
    add-to-cart.min.js?ver=3.4.1:formatted:66 Uncaught TypeError: t(...).addClass(...).fadeTo(...).block is not a function
    

    Can you check if you’re getting the same error when you deactivate the WP menu Cart plugin? Please open a new thread describing the issue and what you have found to avoid confusion!

Viewing 12 replies - 16 through 27 (of 27 total)
  • The topic ‘Not appearing on first item’ is closed to new replies.