• Resolved Damian Nowak

    (@dam6pl)


    Hey!

    Since version 3.7.3 woocommerce_invoice_number hook is no longer available. How can I reproduce this behaviour as using custom invoice number is really important for my website.

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor dwpriv

    (@dwpriv)

    Did you have a code snippet that uses this filter or a plugin that does?

    Thread Starter Damian Nowak

    (@dam6pl)

    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.

    Plugin Contributor alexmigf

    (@alexmigf)

    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.

    Thread Starter Damian Nowak

    (@dam6pl)

    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!

    Plugin Contributor Yordan Soares

    (@yordansoares)

    We are happy to hear that you managed to make it work by your own!

    Let us know if you need anything else 😉

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Missing woocommerce_invoice_number hook’ is closed to new replies.