I trying to remove login and registration at checkout from woocommerce plugin in wordpress
i tried guest checkout but this not working i tried this code
remove_action( 'woocommerce_before_checkout_form', $checkout );
if ( ! $checkout->is_registration_enabled() && $checkout->is_registration_required() && ! is_user_logged_in() ) {
echo esc_html( apply_filters( 'woocommerce_checkout_must_be_logged_in_message', __( 'You must be logged in to checkout.', 'woocommerce' ) ) );
return;
}
When I commented if condition then it opens checkout form but when I clicked place order it gives me this error:
"Create account password is a required field. Account username is a required field."
What I am doing wrong? Any help is welcome.
To remove login form from Woocommerce checkout use:
// Remove login form from checkout
add_action( 'woocommerce_before_checkout_form', 'remove_checkout_login_form', 4 );
function remove_checkout_login_form(){
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_login_form', 10 );
}
To remove Registration from Woocommerce checkout simply use:
add_filter( 'woocommerce_checkout_registration_enabled', '__return_false' );
Both snippets goes in function.php file of your active child theme (or active theme). Tested and works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With