Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter andrearinaldi82

    (@andrearinaldi82)

    I need to insert the date of invoice in the invoice. Can you help?

    function print_order_add_invoice_date( $fields, $order ) {
    	$new_fields = array();
    
    	$order_invoice_date = wcdn_get_order_invoice_date( $order->id );
    	if( $order_invoice_date ) {
    		$new_fields['order_invoice_date'] = array(
    			'label' => __( 'Invoice Date' ),
    			'value' => $order_invoice_date
    		);
    	}
    
    	return array_merge( $fields, $new_fields );
    }
    add_filter( 'wcdn_order_info_fields', 'print_order_add_invoice_date', 10, 2 );
    WPJG

    (@wpjg)

    Could you please specify in what file and where exactly this code needs to be added? – Thanks for your help

    As always: functions.php

    Unfortunatly this shows the “Invoice Date” on both the order slip and the invoice slip. It only should show on the invoice.

    use the wcdn_get_template_type() to check the type of template.

    function print_order_add_invoice_date( $fields, $order ) {
    $new_fields = array();
    
    if( wcdn_get_template_type() == 'invoice' ) {
    	$order_invoice_date = wcdn_get_order_invoice_date( $order->id );
    	if( $order_invoice_date ) {
    		$new_fields['order_invoice_date'] = array(
    			'label' => __( 'Invoice Date' ),
    			'value' => $order_invoice_date
    		);
    	}
    }
    
    return array_merge( $fields, $new_fields );
    }
    add_filter( 'wcdn_order_info_fields', 'print_order_add_invoice_date', 10, 2 );
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Invoice Data’ is closed to new replies.