When a user is new and puts a product in the cart and goes to
finalize purchase, finalizing purchase gives an error and the purchase is not made
purchase (but the new user is generated), when you press a second time
After completing the purchase, the purchase is completed correctly.
To avoid this error we have included a code fragment that when
You click on checkout and it redirects you to the login page.
or registration, and once you have logged in or registered, you will
It redirects back to checkout and works correctly.
We want a new and unregistered user to be able to finish the
purchase and create your user at the same time without any
mistake
The code entered to patch this is:
add_action(‘template_redirect’, ‘woocommerce_custom_redirections’);
function woocommerce_custom_redirections() {
if ( !is_user_logged_in() && is_checkout() )
wp_redirect( get_permalink(
get_option(‘woocommerce_myaccount_page_id’) ) );
}
// LOG REDIRECTION
add_filter(“woocommerce_registration_redirect”, “wcs_register_redirect”);
function wcs_register_redirect($redirect) {
$redirect = “https://miceliongames.com/finalizar-compra/”;
return $redirect;
}
// LOGIN REDIRECTION
add_filter(“woocommerce_login_redirect”, “wcs_register_login”);
function wcs_register_login($redirect) {
$redirect = “https://miceliongames.com/finalizar-compra/”;
return $redirect;
}