woocommerce redirect before checkout



 woocommerce redirect before checkout:

Frist Step :

You can go to your Hosting Cpanel Click on the File Manager.


Then,

Opne Your File manger 

Senonde Step : 

you can click on the public_html/wp-content/themes Select your active theme then 


Click on the function.php file .open your function. PHP file and you can input in this PHP code 


add_action('template_redirect','check_if_logged_in');

function check_if_logged_in() { $pageid = 143; // Tyep your checkout page id if(!is_user_logged_in() && is_page($pageid)) { $url = add_query_arg( 'redirect_to', get_permalink($pagid), site_url('/my-account/') // your my acount url ); wp_redirect($url); exit; } }