To redirect to the checkout page immediately after a product is added to the cart, you can use the woocommerce_add_to_cart_redirect filter.

Add the following code to your theme's functions.php file:

function redirect_to_checkout_on_add_to_cart($url) {

    global $woocommerce;

    $checkout_url = $woocommerce->cart->get_checkout_url();

    return $checkout_url;


add_filter('woocommerce_add_to_cart_redirect', 'redirect_to_checkout_on_add_to_cart');

This code will change the default behavior of adding a product to the cart, directing users to the checkout page instead of the cart page.

Please note that modifying the functionality of your WooCommerce store using custom code can have unintended consequences if not done carefully. Always test these changes on a staging site before implementing them on your live website, and ensure you have a backup of your site before making any modifications.