Forum Replies Created

Viewing 31 replies (of 31 total)
  • Thread Starter absoluteweb

    (@absoluteweb)

    Hi,

    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…

Viewing 31 replies (of 31 total)