I'm trying to set "Add-to-cart" and "Buy Now" buttons in my product page:
- Add-to-cart button: Simply add product in cart
- Buy Now button:Add-to-cart and redirect to checkout page
I've tried this solution found on blogs:
function dj_redirect_checkout( $url ) {
global $woocommerce;
$checkout_url = $woocommerce->cart->get_checkout_url();
return $checkout_url;
}
add_filter( 'add_to_cart_redirect', 'dj_redirect_checkout' );
After adding the above code, add-to-cart also redirects link to checkout page. How to accomplish this for both buttons in the product page?