If you’ve added a cart icon that shows the total items in your cart but it is not updating when an item is added via AJAX unless you reload the page, this fix is for you:

// Update Cart Count After AJAX
add_filter( 'woocommerce_add_to_cart_fragments', 'kd_cart_count_fragments', 10, 1 );
function kd_cart_count_fragments( $fragments ) {
    $fragments['span.replace-with-your-element-class'] = '<span class=".replace-with-your-element-class">' . WC()->cart->get_cart_contents_count() . '</span>';
    return $fragments;

Note: Right click and inspect your cart icon to see the element class. If you change class then you must change fragments class, otherwise the ajax counter won’t work. Keep in mind if you change the content from a ‘span’ element to something else (a div for example), then remember to change the fragments’ element as well. Fragments are cache so in order to see your changes clear or modify your cart.

Disclaimer: This fix might not always work for everyone, if anything happens I am not in any way liable. If you don’t have a backup – that is in no way my problem. If this helped you, share and comment. If you have a better fix, let me know via the comment section below.