• Resolved teresasumisu

    (@teresasumisu)


    Hi!
    I was trying to get the invoice number from the order, because I need to export it for accounting.

    I am talking about this number:
    https://ibb.co/Df2Nx3P (Rechnung 6)

    I used
    $invoices = wc_gzdp_get_invoices_by_order( $order );
    Looped through the invoces, but there is only the String “Rechnung 6” saved and “Lieferschein 3” (Delivery Note… but I don’t even need this one!).

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Dennis

    (@vdwoocommercesupport)

    Hi there,

    you should use:

    $invoices = wc_gzdp_get_invoices_by_order( $order, 'simple' );

    to only get invoices (and no other document types). You can then use:

    $number = $invoice->number;
    $number_formatted = $invoice->number_formatted;

    to get the unformatted and formatted number. Hope this helps.

    Cheers

    Thread Starter teresasumisu

    (@teresasumisu)

    This is not working.

    Tried it:

    $invoice = wc_gzdp_get_invoices_by_order( $order, 'simple');
    
    $billingNr = $invoice->number;
    // and $billingNr = $invoice->number_formatted;

    And I tried it in the foreach, which also did not work.

    This solution is working for me, but it is a full hack:

    
    $invoices = wc_gzdp_get_invoices_by_order( $order, 'simple');
    foreach ($invoices as $inv) {
    $title = $inv->get_title();
    $billingNr = str_replace('Rechnung ', '', $title);
    }
    Plugin Author vendidero

    (@vendidero)

    Hi,

    could you please provide use with the whole logic/snippet? How did you instantiate the $order object? Did you print the $invoices for debugging purposes (e.g. are invoices being found for the specific order)?

    Cheers

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Invoice number from order’ is closed to new replies.