• Resolved Alexander

    (@donatory)


    Hello,

    I need to get the invoice number and put it into the other plugin’s part. For example I have the DHL plugin and I need to put the invoice number to the printable sticker.

    I used this code as a basis:

    $invoice = wcpdf_get_invoice( (array) $order->get_id(), true );
    $invoice_number = $invoice->get_number();
    $plain_invoice_number = $invoice_number->get_plain();

    But it seems it’s only work inside emails’ templates.

    The developer of the DHL Shipping Germany for WooCommerce plugin, gave me this snippet to solve my case:

    add_filter('pr_shipping_dhl_label_args', 'modify_order_id_to_number', 10, 2);

    function modify_order_id_to_number( $args, $order_id ) {
    if ( function_exists( 'wcpdf_get_invoice' ) ) {
    $invoice = wcpdf_get_invoice( $order_id, true );
    $invoice_number = $invoice->get_number();
    $plain_invoice_number = $invoice_number->get_plain();

    $args['dhl_settings']['dhl_label_ref'] = $plain_invoice_number;
    }

    return $args;
    }

    But it doesn’t work.

    Please help me to embed the invoice number into the DHL label.

    • This topic was modified 2 months, 3 weeks ago by Alexander.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor dwpriv

    (@dwpriv)

    You can use $invoice->get_number()->number or get the invoice number from the order data with the _wcpdf_invoice_number meta key.

    Plugin Contributor dwpriv

    (@dwpriv)

    Since we haven’t heard from you in a while, I will mark this topic as resolved. Feel free to reopen it if you still need more help, or open another thread if you need help with something else.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.