Solution:
SO here I am going to explain three steps
Step 1 if you want customer to redirect after adding to cart to checkout then add below code to the functions.php
function my_custom_add_to_cart_redirect( $url ) {
$url = WC()->cart->get_checkout_url();
// $url = wc_get_checkout_url(); // since WC 2.5.0
return $url;
}
add_filter( 'woocommerce_add_to_cart_redirect', 'my_custom_add_to_cart_redirect' );
Step 2 if you want customer to redirect to the cart page after add to cart the following image link showing you can do this from admin end
Step 3 if from admin end it’s not redirecting the customer to the cart page then add following code to your functions.PHP
function custom_add_to_cart_redirect() {
return 'http://localhost:8080/wordpress2/cart/';
}
add_filter( 'woocommerce_add_to_cart_redirect', 'custom_add_to_cart_redirect' );
replace this URL http://localhost:8080/wordpress2/cart/ with your cart page URL hope it will work for you
Thanks