How to make Customer Billing Phone Number Unique in WordPress
-
Actually I want customers to add unique-phone numbers in the billing address of woo-commerce. The users should get an error if the phone number already exists.
I tried the below code but it is not working. Can anyone give me the correct solution for unique phone numbers in Woocommerce?
add_action( 'woocommerce_register_form', 'wooc_Phone_fields' ); function wooc_phone_fields ($username, $email, $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; }
The page I need help with: [log in to see the link]
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘How to make Customer Billing Phone Number Unique in WordPress’ is closed to new replies.