-2

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;
}

1 Answer 1

0

Go to WooCommerce > Settings > Products > General and disable both options: “Redirect to the cart page after successful addition” & “Enable AJAX add to cart buttons on archives“:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.