add custom add to cart handler. update for #5923

based on the recent WooCommerce, so no merge conflicts