How to custom redirect on clicking add to cart in WooCommerce ?
TO do this we first need to make a custom function to handle the url redirect. There are two ways to do so first by using the settings in Woocommerce. Go to Woocommerce menu in Wp-admin and click on settings.
Select Product tab .
Select Display in products Tab.
In this tab find out Add to cart behaviour. In front of this option check the option
Redirect to the cart page after successful addition
That’s it.
If anyone want to redirect to custom page rather than cart then a function is needed to create in functions file of your theme file. Say , redirecting to checkout page. Add following function.
function labotrees_add_to_cart_redirect() { return home_url('checkout' );; }
Now add a filter in function file.
add_filter( 'woocommerce_add_to_cart_redirect', 'labotrees_add_to_cart_redirect' );
That’s it.