How to Update Custom Cart Count with AJAX in WooCommerce?
function totalcartqty(){
?>
<div class=”header-cart-count”><?php echo WC()->cart->get_cart_contents_count(); ?></div>
<?php
}
add_action(‘wp_head’,’totalcartqty’);
add_filter( ‘woocommerce_add_to_cart_fragments’, ‘iconic_cart_count_fragments’, 10, 1 );
function iconic_cart_count_fragments( $fragments ) {
$fragments[‘div.header-cart-count’] = ‘<div class=”header-cart-count”>’ . WC()->cart->get_cart_contents_count() . ‘</div>’;
return $fragments;
}
Read More Posts
- How to get wordpress site title name from url ?
- How to fix If value is infinity, empty and NaN in jQuery?
- How to create custom OTP login in woocommerce without plugin?
- How to redirect in php after resubmittion with button?
- How to enqueue script and css file in child-theme and main plugin file in worpress?