function ek_telefon_alani_woocommerce_kayit_formu() {
?>
<p class="form-row form-row-wide">
<label for="reg_phone"><?php _e( 'Telefon Numarası', 'woocommerce' ); ?><span class="required">*</span></label>
<input type="text" class="input-text" name="phone" id="reg_phone" value="<?php if ( ! empty( $_POST['phone'] ) ) echo esc_attr( $_POST['phone'] ); ?>" />
</p>
<?php
}
add_action( 'woocommerce_register_form', 'ek_telefon_alani_woocommerce_kayit_formu' );
function ek_telefon_alani_woocommerce_kayit_formu_kontrol( $errors, $username, $email ) {
if ( empty( $_POST['phone'] ) ) {
$errors->add( 'phone_error', __( '<strong>Hata</strong>: Telefon numarası boş bırakılamaz.', 'woocommerce' ) );
}
return $errors;
}
add_filter( 'woocommerce_registration_errors', 'ek_telefon_alani_woocommerce_kayit_formu_kontrol' , 10, 3 );
function ek_kullanici_bilgileri_kaydet( $customer_id ) {
if ( isset( $_POST['phone'] ) ) {
update_user_meta( $customer_id, 'billing_phone', sanitize_text_field( $_POST['phone'] ) );
}
}
add_action( 'woocommerce_created_customer', 'ek_kullanici_bilgileri_kaydet' );
Bu kodu aktif temanın functions.php dosyasının en alt satırın ekleyip deneyebilirsin