Minicart Ajax issue
-
Dear Team,
Having an issue with mini cart ajax update. When I am using this function, the ajax “add to cart” not working and minicart widget not working and minicart at my header is not working.
I am using this function –
add_filter('add_to_cart_fragments', 'ta_header_add_to_cart_fragment');
function ta_header_add_to_cart_fragment( $fragments ) { global $woocommerce; ob_start(); ?> <a class="cart-contents" href="<?php echo esc_url($woocommerce->cart->get_cart_url()); ?>" title="<?php esc_attr_e('View your shopping cart', 'royalfood'); ?>"><?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'royalfood'), $woocommerce->cart->cart_contents_count);?></a> <?php $fragments['a.cart-contents'] = ob_get_clean(); return $fragments; }
AND using this on my header to count cart items –
<a class="cart-contents" href="<?php echo esc_url( wc_get_cart_url() ); ?>" title="<?php esc_attr_e('View your shopping cart', 'royalfood'); ?>"><?php echo sprintf(_n('%d item', '%d items', WC()->cart->cart_contents_count, 'royalfood'), WC()->cart->cart_contents_count);?></a>
The above function is not working anymore.
Please help me.
Thanks!
Amit Biswas
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Minicart Ajax issue’ is closed to new replies.