onClick add to cart button, some function call

If you want to add a custom function/behavior onClick of add to cart button then simply place this function into functions.php file.

add_action( 'wp_ajax_nopriv_checking_cart_items', 'checking_cart_items' );
add_action( 'wp_ajax_checking_cart_items', 'checking_cart_items' );
function checking_cart_items() {
    if( isset($_POST['added']) ){
        echo json_encode( sizeof( WC()->cart->get_cart() ) );
    }
    die(); 
}

add_action( 'wp_footer', 'dandd_custom_script' );
function dandd_custom_script() { ?>
    <script type="text/javascript">
    jQuery( function($){
        $(document.body).on('added_to_cart', function(e) {
            $.ajax({
                type: 'POST',
                url: wc_add_to_cart_params.ajax_url,
                data: {
                    'action': 'checking_cart_items',
                    'added' : 'yes'
                },
                success: function (response) {
                    console.log("response: ", response)
                    if( response >= 1 ){
                        console.log("product added...");
                    }
                }
            });
        });
    });
    </script>
<?php }