Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter nagendragowda

    (@nagendragowda)

    Thank you. Please mention that “This plugin supports Debit cards” in plugin description page. it will be useful.

    Thread Starter nagendragowda

    (@nagendragowda)

    Sorry that was a mistake. The plugin working fine.
    Thank you for your support

    Thread Starter nagendragowda

    (@nagendragowda)

    Thank you.

    iam sending emails for “New User – Post-registration Email”.

    iam facing another issue. Recipient User Firstname: [email_user_firstname] shortcode is not working. Also most of the shortcodes are not working.

    Thread Starter nagendragowda

    (@nagendragowda)

    Below is the custom phone field code. This code checks if the phone number exists or not during user registration. But also I want to check the user-profile also (if the phone number is already taken then it should not update there).

    ///Custom Registration Field
    ///////////////////////////////
    // 1. ADD FIELDS
     
    add_action( 'woocommerce_register_form_start', 'bbloomer_add_name_woo_account_registration' );
     
    function bbloomer_add_name_woo_account_registration() {
        ?>
     
        <p class="woocommerce-form-row woocommerce-form-row--wide form-row form-row-wide">
        <label for="reg_phone"><?php _e( 'Phone Number', 'woocommerce' ); ?> <span class="required">*</span></label>
        <input type="tel" class="input-text regular-text billing_phone" name="billing_phone" id="billing_phone" value="<?php if ( ! empty( $_POST['billing_phone'] ) ) esc_attr_e( $_POST['billing_phone'] ); ?>" />
        </p>
     
        <div class="clear"></div>
     
        <?php
    }
     
    ///////////////////////////////
    // 2. VALIDATE FIELDS
     
    add_filter( 'woocommerce_registration_errors', 'bbloomer_validate_name_fields', 10, 3 );
     
    function bbloomer_validate_name_fields( $errors, $username, $email ) {
        if ( isset( $_POST['billing_phone'] ) && empty( $_POST['billing_phone'] ) ) {
            $errors->add( 'billing_phone_error', __( '<strong>Error</strong>: Mobile Number is required!.', 'woocommerce' ) );
        }
        
        if ( isset( $_POST['billing_phone'] ) ) {
            $hasPhoneNumber= get_users('meta_value='.$_POST['billing_phone']);
                if ( !empty($hasPhoneNumber)) {
            $errors->add( 'billing_phone_error', __( '<strong>Error</strong>: Mobile number is already used!.', 'woocommerce' ) );
        }
      }
        return $errors;
    }
     
    ///////////////////////////////
    // 3. SAVE FIELDS
     
    add_action( 'woocommerce_created_customer', 'bbloomer_save_name_fields' );
     
    function bbloomer_save_name_fields( $customer_id ) {
        if ( isset( $_POST['billing_phone'] ) ) {
            update_user_meta( $customer_id, 'billing_phone', sanitize_text_field( $_POST['billing_phone'] ) );
            update_user_meta( $customer_id, 'billing_phone', sanitize_text_field($_POST['billing_phone']) );
        }
     
    }
    • This reply was modified 4 years, 10 months ago by nagendragowda.
    • This reply was modified 4 years, 10 months ago by nagendragowda.
    Thread Starter nagendragowda

    (@nagendragowda)

    I tried below code but it is giving WordPress error.

    add_filter( 'update_user_meta', 'ts_unique_wc_phone_field');
    function ts_unique_wc_phone_field( $errors ) {
        if ( isset( $_POST['billing_phone'] ) ) {
            $hasPhoneNumber= get_users('meta_value='.$_POST['billing_phone']);
                if ( !empty($hasPhoneNumber)) {
            $errors->add( 'billing_phone_error', __( '<strong>Error</strong>: Mobile number is already used!.', 'woocommerce' ) );
        }
      }
        return $errors;
    }
    Thread Starter nagendragowda

    (@nagendragowda)

    I want to validate the Customer billing phone number ( i want to make phone numbers unique ). Because customers going to login to the site using phone numbers. so I want to validate customers’ billing phone number.

Viewing 6 replies - 1 through 6 (of 6 total)