Reputation: 53
In WooCommerce, I need to allow people to checkout without having to register for an account when they buy subscriptions. In Accounts & Privacy in WooCommerce admin section, I have only one option: Enable guest checkout (recommended).
I would like to overwrite wc_create_new_customer()
function code from WooCommerce plugin, located in includes/wc-user-functions.php PHP file, with the following:
function wc_create_new_customer( $email, $username = '', $password = '', $args = array() ) {
if ( empty( $email ) || ! is_email( $email ) ) {
return new WP_Error( 'registration-error-invalid-email', __( 'Please provide a valid email address.', 'woocommerce' ) );
}
if ( email_exists( $email ) ) {
return new WP_Error( 'registration-error-email-exists', apply_filters( 'woocommerce_registration_error_email_exists', __( 'An account is already registered with your email address. <a href="#" class="showlogin">Please log in.</a>', 'woocommerce' ), $email ) );
}
return false;
}
But It seems WooCommerce won't allow overwriting wc_create_new_customer()
function.
Is it possible to overwrite that function used on checkout?
Upvotes: 0
Views: 50
Reputation: 53
The only way is to directly modify the wc_create_new_customer function and block updates for wc to avoid overwriting of the file
Upvotes: 0