Support » Plugin: WooCommerce » [Plugin: WooCommerce – excelling eCommerce] How to display custom checkout fields?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author royho



    for the notification email it’s possible to use this snippet but I can’t chose the title of this custom field.

    My custom field :

    // Hook in
    add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
    // Our hooked in function - $fields is passed via the filter!
    function custom_override_checkout_fields( $fields ) {
         $fields['billing']['naissance'] = array(
            'label'     => __('Date de naissance', 'woocommerce'),
        'placeholder'   => _x('JJ/MM/AAAA', 'placeholder', 'woocommerce'),
        'required'  => true,
        'class'     => array('form-row-wide'),
        'clear'     => true
         return $fields;

    If I use this snippet

    add_filter('woocommerce_email_order_meta_keys', 'my_custom_checkout_field_order_meta_keys');
    function my_custom_checkout_field_order_meta_keys( $keys ) {
    $keys[] = '_naissance';
    return $keys;

    Into the emails notification I obtain

    _naissance: 31/01/1970

    Another solution, I override emails template and chose in which, how and where add my custom field

    Just for admin notifications, in admin-new-order.php I add

    <?php if ($order->order_custom_fields["_naissance"][0]) : ?>
    	<p><strong>Date de naissance :</strong> <?php echo $order->order_custom_fields["_naissance"][0]; ?></p>
    <?php endif; ?>

    Custom fields are linked to the order but I dont no how link them to the customer profile…


    I have added some code to function.php to test the validate function.
    Like bellow :

    add_action('woocommerce_checkout_process', 'my_custom_checkout_field_process');
    function my_custom_checkout_field_process() {
    	global $woocommerce;
    	$woocommerce->add_error( 'Some test ' . __('is a required field.', 'woocommerce') );

    But when I press submit button on Cart, nothing appear …
    Is i did a wrong !

    Please help


    Strange, here is the code I use to date of birth

    add_action('woocommerce_checkout_process', 'my_custom_checkout_field_process');
    function my_custom_checkout_field_process() {
        global $woocommerce;
        if ($_POST['naissance']) {
            $date = explode("/", $_POST['naissance']);
    		if(!checkdate($date[1], $date[0], $date[2]))
    			$woocommerce->add_error( __('<strong>Date de naissance</strong> invalide.') );
    		else {
    			$date18YearsAdded = strtotime(date("Y-m-d", strtotime($date[2].'-'.$date[1].'-'.$date[0])) . " +18 year");
    			if(date("Y-m-d", $date18YearsAdded)>date("Y-m-d"))
    				$woocommerce->add_error( __('<strong>Date de naissance :</strong> vente interdite aux mineurs') );

    @absoluteweb have you figured out how to change the “_naissance”


    _naissance: 31/01/1970

    ? if so, please do share.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: WooCommerce – excelling eCommerce] How to display custom checkout fields?’ is closed to new replies.