In WooCommerce, I am trying to add an extra add to cart button below product summary. I successfully added an extra button following this code which works for single products:
add_action( 'woocommerce_single_product_summary', 'custom_button_after_product_summary', 30 );
function custom_button_after_product_summary() {
global $product;
echo "<a href='".$product->add_to_cart_url()."'>add to cart</a>";
}
But if the product is a variation it doesn't work.
please suggest as what to do?
I have revisited your code a bit, and added a 2nd hooked function for variable products:
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
You will get this on variable products: