woocommerce checkout manager confirm password

Solutions on MaxInterview for woocommerce checkout manager confirm password by the best coders in the world

showing results for - "woocommerce checkout manager confirm password"
Mia
01 Oct 2018
1add_filter( 'woocommerce_checkout_fields' , 'add_confirm_password_checkout_field', 10, 1 );
2function add_confirm_password_checkout_field( $fields ) {
3    if ( get_option( 'woocommerce_registration_generate_password' ) != 'no' )
4        return $fields;
5
6    $fields['account']['account_password']['class'] = array('form-row-first');
7    $fields['account']['account_password-2'] = array(
8        'type' => 'password',
9        'label' => __( 'Password confirmation', 'woocommerce' ),
10        'required'          => true,
11        'placeholder' => _x('Confirmation', 'placeholder', 'woocommerce'),
12        'class' => array('form-row-last'),
13        'label_class' => array('hidden')
14    );
15    return $fields;
16}
17
18add_action( 'woocommerce_checkout_process', 'confirm_password_checkout_validation' );
19function confirm_password_checkout_validation() {
20    if ( ! is_user_logged_in() && ( WC()->checkout->must_create_account || ! empty( $_POST['createaccount'] ) ) ) {
21        if ( strcmp( $_POST['account_password'], $_POST['account_password-2'] ) !== 0 )
22            wc_add_notice( __( "Passwords doesn’t match.", "woocommerce" ), 'error' );
23    }
24}
25