• Resolved qtfish

    (@qtfish)


    so i was able to get a custome field placed on the checkout page and it works fine.
    i was also able to place the answer on to the order edit as well
    Now only problem is i cant get the answer from customer to print on the PRINT INVOICE.
    
    Is there a way to get the answer on the printed paper using Print Invoice button
    
    here is the code i used
    
    /**
     * Add the field to the checkout
     */
    add_action( 'woocommerce_after_order_notes', 'my_custom_checkout_field' );
    
    function my_custom_checkout_field( $checkout ) {
    
        echo '<div id="my_custom_checkout_field"><h2>' . __('Delivery Day Preference') . '</h2>';
    
        woocommerce_form_field( 'my_field_name', array(
            'type'          => 'text',
            'class'         => array('my-field-class form-row-wide'),
            'label'         => __('What delivery day works best for you?'),
            'placeholder'   => __('Wednesday/Thursday/Friday or any combination of these 3 days'),
            ), $checkout->get_value( 'my_field_name' ));
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Upendra Kapse

    (@wpupen)

    Hello,

    Yes, we do have a function using which you can display an additional field in the Invoice. Here’s an example field that adds the VAT field, you can make changes in this function by changing the field label to your own field label and also by changing the meta key to the meta key of your field that you want to add to the Invoice:

    * Add this code snippet in functions.php file of your currently active theme.
     * An example that adds a 'VAT' field to the end of the list. 
    
    function example_custom_order_fields( $fields, $order ) {
        $new_fields = array();
            
        if( get_post_meta( $order->id, 'your_meta_field_name', true ) ) {
            $new_fields['your_meta_field_name'] = array( 
                'label' => 'VAT',
                'value' => get_post_meta( $order->id, 'your_meta_field_name', true )
            );
        }
        return array_merge( $fields, $new_fields );
    }
    add_filter( 'wcdn_order_info_fields', 'example_custom_order_fields', 10, 2 );

    I hope this helps.

    Kind Regards,
    Upendra.

    Thread Starter qtfish

    (@qtfish)

    awesome that works thank you

    Plugin Support Upendra Kapse

    (@wpupen)

    @qtfish Glad to know that worked well ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom field answer on print invoice’ is closed to new replies.