Woo 3.0.8 ajax fragments do NOT update cart menu
We are using WP Cart Menu Pro and on our store page we have added Ajax to cart which works great but does not update Items in cart menu.
It just started with an automatic upgrade to WooCommerce 3.0.8. I did some research and added the below code to our functions.php page:
function my_header_add_to_cart_fragment( $fragments ) {
global $woocommerce;
ob_start();
?><a class="wpmenucart-contents" href="https://www.springbokbbq.co.uk/cart/" title="View your shopping cart">
<i class="wpmenucart-icon-shopping-cart-5"></i>
<span class="cartcontents"><?php echo sprintf (_n( '%d item', '%d items', WC()->cart->get_cart_contents_count() ), WC()->cart->get_cart_contents_count() ); ?></span>
</a><?php
$fragments['a.wpmenucart-contents'] = ob_get_clean();
return $fragments;
}
add_filter( 'woocommerce_add_to_cart_fragments', 'my_header_add_to_cart_fragment' );
Has anyone else faced this issue with Woo update?
EDIT:
I checked the chrome console: when I click "Add to Cart" I get this error:
Uncaught TypeError: a(...).addClass(...).fadeTo(...).block is not a function
at String.<anonymous> (add-to-cart.min.js?ver=3.0.8:4)
at Function.each (jquery.js?ver=1.12.4:2)
at HTMLDocument.b.updateFragments (add-to-cart.min.js?ver=3.0.8:4)
at HTMLDocument.dispatch (jquery.js?ver=1.12.4:3)
at HTMLDocument.r.handle (jquery.js?ver=1.12.4:3)
at Object.trigger (jquery.js?ver=1.12.4:3)
at Object.a.event.trigger (jquery-migrate.min.js?ver=1.4.1:2)
at HTMLBodyElement.<anonymous> (jquery.js?ver=1.12.4:3)
at Function.each (jquery.js?ver=1.12.4:2)
at a.fn.init.each (jquery.js?ver=1.12.4:2)
I don't get this error when deleting items from the cart and updating the Cart Items menu on the cart page.
+3
source to share
No one has answered this question yet
Check out similar questions: