• Resolved hashexpert

    (@hashexpert)


    Hello!

    How can I create a custom invoice number format with a filter. For example I want my invoice number always match order_id from wordpress.

    Thank you

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    If you’re from the EU I wouldn’t recommend using the order number as invoice number because that will leave gaps in the numbering (even with plugins like Sequental Order Numbers!). But it’s certainly possible, see:
    Why is the PDF invoice number different from the woocommerce order number?
    But I want the invoice to have the same number as the order!

    Thread Starter hashexpert

    (@hashexpert)

    hello! thanks for your quick answer.
    this solution absolutely worked for me

    Thread Starter hashexpert

    (@hashexpert)

    What if I want to use both order number and separate invoice number?

    for example now I have my settings as follows: https://prntscr.com/oc0at3

    how can I add another “-” and then order_id to the end with a filter, to make in invoice number be: [invoice_month]-INV_NUMBER-ORDER_NUMBER ?

    thank you

    Plugin Contributor Ewout

    (@pomegranate)

    You can already use [order_number] in the format settings (suffix in your case), no need for a filter there ??

    But if you do need to filter, you could try `

    Here’s an example:

    
    add_filter( 'wpo_wcpdf_format_document_number', 'wpo_wcpdf_custom_invoice_number', 10, 4 );
    function wpo_wcpdf_custom_invoice_number( $formatted_number, $number, $document, $order ) {
    	if ( $document->type == 'invoice' ) {
    		$formatted_number = $formatted_number . $order->get_order_number();
    	}
    	return $formatted_number;
    }
    
    Thread Starter hashexpert

    (@hashexpert)

    This absolutely solved my problem.
    On the settings page only parts of the date are written in a hint, I won’t ask if I knew about [order_number]

    Thank you for your help

    Plugin Contributor Ewout

    (@pomegranate)

    Glad to hear that resolved the issue, I’ll see if we can add some more documentation about that (there are several other placeholders that you can use there)

    Happy selling!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Create an invoice number mask with a filter’ is closed to new replies.