Saturday, February 4, 2023
HomeWordPress Developmentplugin growth - Fetch Customized Woocomerce filed information and verify the information...

plugin growth – Fetch Customized Woocomerce filed information and verify the information avialble in Wp-user desk as nicname or username utilizing perform.php


I write a code for add customized filed in checkout kind as add affiliate code I need to match that customized subject information with username. If customized subject information match with any of the username the chcekout course of transfer additional different smart present error. I’ve write one thing but it surely’s not working please assist to resolve this concern.

Right here is my code:

// including customized filed

add_action('woocommerce_before_checkout_form', 'custom_checkout_field');

perform custom_checkout_field($checkout)

{

echo '<div id="custom_checkout_field"><h2>' . __('Add Reference Affiliate Code') . '</h2>';

woocommerce_form_field('custom_field_name', array(

'sort' => 'textual content',

'class' => array(

'my-field-class form-row-wide'

) ,

'label' => __('Affiliate Code') ,

'placeholder' => __('Affiliate Code') ,

) ,

$checkout->get_value('custom_field_name'));

echo '</div>';

}

// Chcek customized filed information with username

add_action('woocommerce_checkout_process', 'custom_checkout_field_validation');
perform custom_checkout_field_validation() {
    if(username_exists( $_POST['custom_field_name'] )){
        
    }else{
        echo $_POST['custom_field_name'];
        wc_add_notice( __( $_POST['custom_field_name']), 'error' );
        wc_add_notice( __( 'Lütfen Geçerli TC Kimlik No Girin.' ), 'error' );
    }
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments