Support » Plugins and Hacks » [Resolved] invoice number vs invoice order

[Resolved] invoice number vs invoice order

Viewing 15 replies - 1 through 15 (of 28 total)
  • Plugin Author Ewout


    I don’t know of a plugin with such functionality, WooCommerce Sequential Order Numbers is good, but it also counts cancelled orders (note that the order number is not the same as the WooCommerce order ID!).

    Technically, at least in a lot of european countries, you have to keep the invoice for the cancelled order and create a credit note (which at least in the Netherlands can have a separate numbering system!).

    Based on the new rule of VAT in UE, which mainly says that the invoice should be issued when the payment is received.

    When using payment transfer (ipo credit card) + when the user never pays, there is no reason to issue an invoice, despite that an order number has been used …

    "you have to keep the invoice for the cancelled order and create a credit note
    Ps: the invoice is issued when order is finished….. it means that I have to finish the order , issue the invoice, create a credit note adn unsubscibe the user ?

    if payment not reveiced = gap in invoice sequence

    Plugin Author Ewout


    I understand that everyone’s needs are different, so I added a sequential invoice number functionality. I’ll release it as beta first, I’d like to know what you think. You can download this development version here:


    The invoice numbers start numbering from the first order_id you create an invoice for, to prevent confusion.

    you can call the invoice number with the following code in your template:

    ?php $wpo_wcpdf->invoice_number(); ?>

    if you want to add a prefix or reduce the count, add 10000 etc, you can filter the invoice value with the following code in your functions.php (modify to your liking):

    add_filter( 'wpo_wcpdf_invoice_number', 'wpo_wcpdf_invoice_number' );
    function wpo_wcpdf_invoice_number($invoice_number) {
    	$prefix = 'ABC';
    	$current_year = date("Y");
    	$offset = 10000;
    	$invoice_number = $prefix . $current_year . ($offset + $invoice_number);
    	return $invoice_number;

    thanks, I will ask some help for these code…

    So I uploaded your plugin which is the best one I tried !

    I do not see the invoice number appearing but I guess I should first put this code !!

    thanks a lot ! great job !

    I recommand this plugin to everybody !! If the invoice number is implemented as default setting, … 🙂 would be nice !

    Plugin Author Ewout


    whoops, noticed that there was a < missing in the first code snippet!!!!

    <?php $wpo_wcpdf->invoice_number(); ?>

    I will not make the invoice number implemented as a default setting, but I will consider putting it on the settings page, so people can choose. Some people use the Sequential Order Number plugin already, and if it then uses an even different number it gets messy/confusing.

    sorry, that’s what I wanted to mean : to put the settings (invoice num or not) as default ….

    Plugin Author Ewout


    Allright, a little present for you :o)
    If you checkout the latest development version, it contains two new settings in the template settings pane:

    • Number to display on invoice (order number or invoice number)
    • Date to display on invoice (order date or invoice date)

    Let me know what you think!


    I do not see these setting in the “model” tab… I downladed the version 1.1.6 (before I had 1.1.7 .. (?))

    thank you 🙂

    Plugin Author Ewout


    You have downloaded the release version, you need the development version!

    (which you can also find under:

    thank you,

    I see now the settings now.

    But I’m using “the WooCommerce order number”
    so, it will use the order number as invoice number in any case, that’s what I would like to avoid.

    The invoice date never appear also on the invoice, I always have the order date..

    Thank you

    Plugin Author Ewout


    I’m not sure I understand. If you go to the template settings panel and set it to:
    “Built in sequential invoice number”
    “Invoice date”

    does that not work for you? Are you using the default simple template?

    Hey Ewout,

    Just awesome, thx!

    Just tested your dev version. Not sure if I understand right but it seems to me that you either show the order or invoice number/date. It looks for me that the functions returns one or the other. But haven’t time to seriously test or look into the code … pretty bussy right now sorry 🙁

    I probably would recommend to have 4 functions so everyone can choose in the template which to show:

    <?php $wpo_wcpdf->invoice_number(); ?>
    <?php $wpo_wcpdf->invoice_date(); ?>
    <?php $wpo_wcpdf->order_number(); ?>
    <?php $wpo_wcpdf->order_date(); ?>

    in my opinion for customers it’s best to show all 4, that they know which order the invoice belongs to.

    Your checkbox may than only refer to the default template to turn the visibility of the invoice number and invoice date on and off.

    More feature ideas
    – I would add a prefix, suffix and a offset field to the template screen.
    – Than I would add {year} as a replacement code.
    – Ajax function to set/reset the current invoice counter.

    Hi Ewout, probably this idea is not right in this thread, but have you thought of moving the plugin code from svn to git to allow pull and push requests? This would allow other programmers to contribute to the code easily.

    Plugin Author Ewout


    Hi funnyprinter,
    All 4 functions that you propose are present (with the exact names that you give!) and usable, but for simplicity purposes I won’t include all those dates and numbers in the default. The setting actually replaces the order number by the invoice number and same for the order date. It’s not the most semantical way to do it, but from the user perspective it makes it easy for most users while the flexibility for others is still there.

    For now I will keep the prefix, suffix & offset in a filter, but I might move that to the settings pane in a later stage. I just realized that the year should be the order year, otherwise it gets messy if you want to print last years invoices.

    $order_year = date_i18n( 'Y', strtotime( $wpo_wcpdf->get_order_date() ) );

    About git vs. svn: I am actually using a private git repo to manage my own code, I could just move that to a public repo. I will still need to use SVN to publish the code on wordpress.org, but that’s no different from how it is now. Will think about it, thanks!

    Plugin Author Ewout


    1.2.0 is now released! I included the invoice number filter suggestion in the FAQ too:

    add_filter( 'wpo_wcpdf_invoice_number', 'wpo_wcpdf_invoice_number', 10, 4 );
    function wpo_wcpdf_invoice_number( $invoice_number, $order_number, $order_id, $order_date ) {
    	$prefix = 'ABC';
    	$order_year = date_i18n( 'Y', strtotime( $order_date ) );
    	$offset = 10000;
    	$invoice_number = $prefix . $order_year . ($offset + $invoice_number);
    	return $invoice_number;

    Off course you can add a suffix, do whatever. You can use the order number, order id and order date to create additional strings, the order_id even allows you to access all order data directly (although I recommend to minimize this to save memory).

Viewing 15 replies - 1 through 15 (of 28 total)
  • The topic ‘[Resolved] invoice number vs invoice order’ is closed to new replies.