Get invoice number outside the plugin
-
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.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.