The code snippet for redirecting the add to cart to the checkout page only works when I press the add to cart on the SINGLE PRODUCT PAGE. It does not work when I click the add to cart button on the SHOP PAGE of my woocommerce website.
Here is the code snippet that I am using. How do I change this so that when I click the add to cart button on the SHOP PAGE, it is also redirected to the CHECKOUT PAGE.
add_filter('add_to_cart_redirect', 'lw_add_to_cart_redirect');
function lw_add_to_cart_redirect() {
global $woocommerce;
$lw_redirect_checkout = $woocommerce->cart->get_checkout_url();
return $lw_redirect_checkout;
}