function custom_cart_count_fragments( $fragments ) {
    $fragments['span.cart-totals'] = '<span class="cart-totals">' . sprintf( WC()->cart->get_cart_contents_count() ); '</span>';
    return $fragments;
}


function mobile_cart_count_fragments( $fragments ) {
    $fragments['span.cart-mobiles'] = '<span class="cart-mobiles">' . sprintf( WC()->cart->get_cart_contents_count() ); '</span>';
    return $fragments;
}


add_filter( 'woocommerce_add_to_cart_fragments', 'custom_cart_amount_fragments', 10, 1 );
function custom_cart_amount_fragments( $fragments ) {
    $fragments['span.cart-amount'] = '<span class="cart-amount">' . WC()->cart->get_cart_total() . '</span>';
    return $fragments;
}