• Resolved Zlato

    (@zlato)


    Hi guys
    Fails to add attributes when order print.
    Attribute is “author”

    i use this code from FAQ

    function example_custom_order_fields( $fields, $order ) {
        $new_fields = array();
    
        if( get_post_meta( $order->id, 'author', true ) ) {
            $new_fields['author'] = array( 
                'label' => 'VAT',
                'value' => get_post_meta( $order->id, 'author', true )
            );
        }
    
        if( get_post_meta( $order->id, 'author', true ) ) {
            $new_fields['author'] = array( 
                'label' => 'Author',
                'value' => get_post_meta( $order->id, 'author', true )
            );
        }
    
        return array_merge( $fields, $new_fields );
    }
    add_filter( 'wcdn_order_info_fields', 'example_custom_order_fields', 10, 2 );
Viewing 1 replies (of 1 total)
  • Plugin Support Upendra Kapse

    (@wpupen)

    Hello,

    Are you referring to the attribute the customer selected on your variable product? If yes, the selected attribute will appear automatically on the Invoice as you can see in this screenshot: https://prnt.sc/1xol4aj

    Also, if it is a custom order meta field that you have added on the checkout page then please make sure that the meta key that you have used matches with the meta key of your author field. And the above snippet adds two fields so you can remove one of the if conditions.

    Kind Regards,
    Upendra.

Viewing 1 replies (of 1 total)
  • The topic ‘Add attributes to print order’ is closed to new replies.