Plugin Contributor
dwpriv
(@dwpriv)
Did you have a code snippet that uses this filter or a plugin that does?
I use it in my custom solution.
\add_filter('woocommerce_invoice_number', 'custom_invoice_number', 10, 2);
/**
* Generate custom invoice number for order.
*/
function custom_invoice_number(?string $invoiceNumber, int $orderId): string
{
$order = \wc_get_order($orderId);
return $order->get_date_modified()->format('Y') . '/' . $order->get_customer_id() . '/' . $orderId;
}
Filter until version 3.7.2 was available in the file woocommerce-pdf-invoices-packing-slips/includes/documents/abstract-wcpdf-order-document-methods.php
on line 1166.
Could you try this instead?
add_filter( 'woocommerce_invoice_number_by_plugin', '__return_true' );
add_filter( 'wpo_wcpdf_external_invoice_number', function ( $number, $invoice ) {
if ( ! empty( $invoice->order ) ) {
$order = $invoice->order;
$number = $order->get_date_modified()->date_i18n( 'Y' ) . '/' . $order->get_customer_id() . '/' . $order->get_id();
}
return $number;
}, 10, 2 );
Let us know.
Your solution didn’t work fully as I expected, but I found wpo_wcpdf_invoice_number
which resolved the issue.
Anyway, thank you for your support!
We are happy to hear that you managed to make it work by your own!
Let us know if you need anything else 😉