How do I add invoice information meta?

In order to add invoice information meta to the PF invoice template, simply add the following filter to your themes  functions.php

/**
 * Add PDF invoice information meta (from third party plugins).
 *
 * @param array         $info Invoice info meta.
 * @param BEWPI_Invoice $invoice Invoice object.
 * @since 2.9.8
 *
 * @return array.
 */
function add_invoice_information_meta( $info, $invoice ) {
    $payment_gateway = wc_get_payment_gateway_by_order( $invoice->order );

    // Add PO Number from 'WooCommerce Purchase Order Gateway' plugin.
    if ( $payment_gateway && 'woocommerce_gateway_purchase_order' === $payment_gateway->get_method_title() ) {
        $po_number = WPI()->get_meta( $invoice->order, '_po_number' );
        if ( $po_number ) {
            $info['po_number'] = array(
                'title' => __( 'Purchase Order Number:', 'woocommerce-pdf-invoices' ),
                'value' => $po_number,
            );
        }
    }

    // Add VAT Number from 'WooCommerce EU VAT Number' plugin.
    $vat_number = WPI()->get_meta( $invoice->order, '_vat_number' );
    if ( $vat_number ) {
        $info['vat_number'] = array(
            'title' => __( 'VAT Number:', 'woocommerce-pdf-invoices' ),
            'value' => $vat_number,
        );
    }

    return $info;
}
add_filter( 'wpi_invoice_information_meta', 'add_invoice_information_meta', 10, 2 );<br>
	

Please test the functionality on a development environment of your website. If it ceases to work, please revert back to the original state of your website and follow the tutorial again.

Still need help? Contact Us Contact Us