Woocomerce Checkout With Email As Optional

By default, Woocommerce checkout or any other plugin on Woocommerce will require email to checkout.

However, you might want to disable it due to some reason.

Although some plugins do provide the option to make the user email during checkout as optional, however, it might not work very well.

One of the solutions is to force the email to be there although user did not enter their email.

Code as bellow.

add_action( 'woocommerce_checkout_process', 'custom_woocommerce_checkout_process' );

function custom_woocommerce_checkout_process() {
    // Check if the email field is empty
    if ( empty( $_POST['billing_email'] ) ) {
        // Set a dummy email
        $dummy_email = '[email protected]';
        $_POST['billing_email'] = $dummy_email;
    }
}

You can use Code Snippet plugin to use this.

The code above will submit “[email protected]” on the backend or during checkout if the user did not fill up their email.

Please change the email accordingly.

Leave a Reply

Your email address will not be published. Required fields are marked *