Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hi!
    It depends on whether the PDF plugin is loaded when the receipt is created, which is most likely the case. The following code should do the trick:

    global $wpo_wcpdf;
    $wpo_wcpdf->export->set_invoice_number($order->id);
    echo $wpo_wcpdf->export->get_invoice_number($order->id);

    This assumes that the order is loaded in the $order object, I don’t know if that’s the case for this plugin. Another possibility is to get the order id from a separate variable. The WooCommerce POS developers should definitely be able to help with this – you can refer them to this thread.

    Let me know if you have any other questions!

    Hi @ewout & @eyby,

    WooCommerce POS uses the WC REST API. Ideally the WooCommerce PDF Invoices & Packing Slips plugin should be updated to be compatible with the API, alternatively the user can use a filter in their functions.php file, eg:

    function add_wpo_wcpdf_invoice_number($data, $order){
        global $wpo_wcpdf;
        $data['wpo_wcpdf_invoice_number'] = $wpo_wcpdf->export->get_invoice_number($order->id);
        return $data;
    }
    add_filter( 'woocommerce_api_order_response', 'add_wpo_wcpdf_invoice_number', 10, 2 );

    The above is untested but should add the invoice number to the order response.

    Now, you just need to add that new variable to your POS receipt template:

    <tr>
      <th><?php /* translators: woocommerce */ _e( 'Order Number', 'woocommerce' ); ?></th>
      <td>{{order_number}}</td>
    </tr>
    <tr>
        <th><?php _e( 'Invoice Number:', 'wpo_wcpdf' ) ?></th>
        <td>{{wpo_wcpdf_invoice_number}}</td>
    </tr>

    Thread Starter EYBY

    (@eyby)

    Morning,

    thanks for fast reply. Unfortunately it doesnt work or miss something to work. The Field where the Number should be displayed is still clean after printing.

    Thanks for the effort!

    Thread Starter EYBY

    (@eyby)

    The Field where the Number should be displayed is still clean after printing.

    Or on some Orders it display “false”.

    You could try some debugging on that woocommerce_api_order_response, eg:

    function add_wpo_wcpdf_invoice_number($data, $order){
        $data['wpo_wcpdf_invoice_number'] = 'test';
        return $data;
    }
    add_filter( 'woocommerce_api_order_response', 'add_wpo_wcpdf_invoice_number', 10, 2 );
    Thread Starter EYBY

    (@eyby)

    @ kilbot,

    after clearing the records and let it reload the Orders it has started to work now.
    PS:I have added 2 lines to orders.php to let it display the Invoice Number there too.

    I′m thankfull it do work now!

    Kind Regards and many Thanks for Support @kilbot @ewout

    Plugin Contributor Ewout

    (@pomegranate)

    Thanks @kilbot for the support! I will look into adding this to the core plugin (keep an eye on the changelog EYBY!).

    Have a great day!

    Ewout

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How do i get Invoice Number to display it on other PDF’ is closed to new replies.