Customizing the add to cart function

To do this you need to use the woocommerce ‘woocommerce_add_to_cart’ hook to add your custom function. something like this :

add_action('woocommerce_add_to_cart', 'my_function');
function my_function(){
    //........
}

This has been answered in another question here : https://stackoverflow.com/a/34255005/3134410