Loading...
  1. Welcome to the Upload WP Community Forums!  This is the best place to get premium WordPress and WooCommerce support.  Please take a look around and join the Upload WP Community for FREE today!

Customised field not in order email

Discussion in 'General WooCommerce Discussion' started by Ian Alport, Jan 11, 2017.

  1. Ian Alport

    Ian Alport New Member Updated Profile

    Hi,

    I have added a phone number field to the delivery address of Woocommerce succesfully, the only problem is that the phone number does not appear in the order email sent to the supplier. Although the web page where I fund this solution claims it does do this. This is the code I added to functions.php in the child theme:

    PHP:
    // 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['shipping']['shipping_phone'] = array(
            
    'label'    => __('Phone''woocommerce'),
        
    'placeholder'  => _x('Phone''placeholder''woocommerce'),
        
    'required'  => true,
        
    'class'    => array('form-row-wide'),
        
    'clear'    => true
        
    );

        return 
    $fields;
    }

    /**
    * Display field value on the order edit page
    */
    add_action'woocommerce_admin_order_data_after_shipping_address''my_custom_checkout_field_display_admin_order_meta'10);

    function 
    my_custom_checkout_field_display_admin_order_meta($order){
        echo 
    '<p><strong>'.__('Phone From Checkout Form').':</strong> ' get_post_meta$order->id'_shipping_phone'true ) . '</p>';
    }
    Can anyone tell what is wrong and how can I fix it?

    Ian