function addmobilephone() {?>
<p class="form-row form-row-wide">
<label for="b_phone">موبایل *</label>
<input type="text" class="input-text" name="b_phone" id="b_phone" value="" />
</p>
<div class="clear"></div>
<?php
}
add_action( 'woocommerce_register_form_start', 'addmobilephone' );
function phonecheck( $username, $email, $validation_errors ) {
if ( isset( $_POST['b_phone'] ) && empty( $_POST['b_phone'] ) ) {
$validation_errors->add( 'b_phone_error', __( '<strong>وارد کردن شماره موبایل الزامی است!</strong>', 'woocommerce' ) );
}
return $validation_errors;
}
add_action( 'woocommerce_register_post', 'phonecheck', 10, 3 );
function savephone( $customer_id ) {
if ( isset( $_POST['b_phone'] ) ) {
update_user_meta( $customer_id, 'billing_phone', sanitize_text_field( $_POST['b_phone'] ) );
}
}
add_action( 'woocommerce_created_customer', 'savephone' );