• Resolved User

    (@lostguybrazil)


    Hi,

    I would like to know if it is possible to get from a given order (e.g. $order_id = 1234;) the respective (1) invoice created (true/false); (2) invoice date; and (3) invoice number.

    Many thanks!

    Kind regards

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author vendidero

    (@vendidero)

    Hi there,

    of course it is – you’ll need to either use the REST API to retrieve the invoice(s) (see https://vendidero.de/dokument/invoices-rest-api) to an order or the PHP methods supplied by the StoreaBill package within woocommerce-germanized-pro/packages/storeabill to retrieve the information.

    PS: Please use our help desk on support for out professional version:?https://vendidero.de/dashboard/help-desk

    Best,
    Dennis

    Thread Starter User

    (@lostguybrazil)

    Hi Dennis, thank you for your answer. I was able to retrieve it – here’s the code for future reference.

    Thanks!

    $order_id = 1234;
    $order = wc_get_order($order_id);
    $invoice = wc_gzdp_get_order_last_invoice($order);

    if ($invoice) {
    // Invoice exists
    echo "Invoice Created: True<br>";

    // Get the invoice date
    $invoice_date = $invoice->get_date_created();
    echo "Invoice Date: " . $invoice_date->date('Y-m-d H:i:s') . "<br>";

    // Get the invoice number
    $invoice_number = $invoice->get_formatted_number();
    echo "Invoice Number: " . $invoice_number . "<br>";
    } else {
    // No invoice found
    echo "Invoice Created: False<br>";
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.