'How to add a Woocommerce buy now button for variable products without plugin?
I wish to ADD a "buy now" button on product page for variable products. I tried many snippets code but those are working only for simple products.
function add_content_after_addtocart() {
$current_product_id = get_the_ID();
$product = wc_get_product( $current_product_id );
$checkout_url = wc_get_checkout_url();
if( $product->is_type( 'simple' ) ){
echo 'Buy Now';
}
}
add_action( 'woocommerce_after_add_to_cart_button', 'add_content_after_addtocart' );
above code is only working for simple products. In the same way I would like to create buy now button on variation product page. Please do help
Thank you.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
