WordPress.org

Forums

WooCommerce PDF Invoices & Packing Slips
[resolved] invoice number vs invoice order (29 posts)

  1. oligou
    Member
    Posted 1 year ago #

    Hi,

    I'm searching a plugin making invoice with a separate number than order number.

    To be clear : this two numbers are completly different !!

    A canceled order will create a gap in the invoices sequence... so ..

    thanks

    http://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/

  2. Ewout
    Member
    Plugin Author

    Posted 1 year ago #

    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!).

  3. oligou
    Member
    Posted 1 year ago #

    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

  4. Ewout
    Member
    Plugin Author

    Posted 1 year ago #

    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:

    http://downloads.wordpress.org/plugin/woocommerce-pdf-invoices-packing-slips.zip

    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;
    }
  5. oligou
    Member
    Posted 1 year ago #

    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 !

  6. Ewout
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  7. oligou
    Member
    Posted 1 year ago #

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

  8. Ewout
    Member
    Plugin Author

    Posted 1 year ago #

    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!

  9. oligou
    Member
    Posted 1 year ago #

    thanks,

    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 :-)

  10. Ewout
    Member
    Plugin Author

    Posted 1 year ago #

    You have downloaded the release version, you need the development version!
    http://downloads.wordpress.org/plugin/woocommerce-pdf-invoices-packing-slips.zip

    (which you can also find under:
    http://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/developers/

  11. oligou
    Member
    Posted 1 year ago #

    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

  12. Ewout
    Member
    Plugin Author

    Posted 1 year ago #

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

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

  13. funnyprinter
    Member
    Posted 1 year ago #

    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.

  14. funnyprinter
    Member
    Posted 1 year ago #

    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.

  15. Ewout
    Member
    Plugin Author

    Posted 1 year ago #

    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!

  16. Ewout
    Member
    Plugin Author

    Posted 1 year ago #

    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).

  17. Chirag Vora
    Member
    Posted 1 year ago #

    How can month be added in above snippet? for example order for January 2013, your snippet will print:

    ABC2013100xx

    How to make it display along with month before year:

    ABC012013100xx

  18. Chirag Vora
    Member
    Posted 1 year ago #

    How can we display all four namely order number, order date, invoice number and invoice date.
    Any snippet for "Simple" templete?

  19. Ewout
    Member
    Plugin Author

    Posted 1 year ago #

    you can get the order month with the following code:

    $order_month = date_i18n( 'n', strtotime( $order_date ) );

    Or the complete year+month directly:

    $order_yearmonth = date_i18n( 'Yn', strtotime( $order_date ) );

    The example in the FAQ is more up to date that the above and includes padding and your xx suffix 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 ) );
        $order_month = date_i18n( 'n', strtotime( $order_date ) );
        $padding = 6; // number of digits - so 42 becomes 000042
        $suffix = 'xx';
        $invoice_number = $prefix . $order_year . $order_month . sprintf('%0'.$padding.'d', $invoice_number) . $suffix ;
        return $invoice_number;
    }
  20. Chirag Vora
    Member
    Posted 1 year ago #

    $order_month = date_i18n( 'n', strtotime( $order_date ) );
    or
    $order_yearmonth = date_i18n( 'Yn', strtotime( $order_date ) );

    both are not displaying month in my case.

  21. Ewout
    Member
    Plugin Author

    Posted 1 year ago #

    Have you tried the full filter as given? You will need to include these strings in the filename too :)

  22. Chirag Vora
    Member
    Posted 1 year ago #

    hmm, I got it but it may become difficult to fins the invoice because February is printed as 2 and not 02
    When using offset may lead to confusion for November and December might look like January.

  23. Ewout
    Member
    Plugin Author

    Posted 1 year ago #

    Ah yes, but you gave 20131 as an example :o)
    you need 'm' instead of 'n' if you want a leading zero.
    more info: PHP date

  24. Chirag Vora
    Member
    Posted 1 year ago #

    Ah my bad. Thank you again.

  25. Nano09
    Member
    Posted 1 year ago #

    sorry to ask again, but I'm not sure I understand.

    My invoice says:

    Order Date:
    Invoice Number:
    Payment Method:

    I would like to add "Order number" in the invoice as well so it looks like:

    Order Date:
    Invoice Number:
    Order number:
    Payment Method:

    Would have been nice to have that as an option in the settings so you have to tick what fields you want to include in the invoice.

    So, it seems like I need to add "<?php $wpo_wcpdf->order_number(); ?>", but I'm not sure where....

    Would it be in any of the "Extra template fields". If so, would that make it appear below "Invoice number?"

    Thanks for your help Ewout! :-)

  26. Ewout
    Member
    Plugin Author

    Posted 1 year ago #

    Hi Nano,
    To make these kind of changes, you need to edit the template files (invoice.php).
    Make a copy of the Simple template (see FAQ for instructions), then open up invoice.php in the new location

    over there you can insert the following after line 55 (the line that starts with <span class="order-number">):

    <span class="order-number-label"><?php _e( 'Order Number:', 'wpo_wcpdf' ); ?></span>
    <span class="order-number"><?php $wpo_wcpdf->order_number(); ?></span><br />

    Unfortunately it's not possible right now to change this is the settings, but I will consider adding this to a future version.

    Have a great day!
    Ewout

  27. Nano09
    Member
    Posted 1 year ago #

    Thank you Ewout! Now I get it. I was able to do it following your instructions. :-)

  28. RJWJ
    Member
    Posted 1 year ago #

    I consider it useful to display the order date aswel as the invoice date.

    Is it possible to do the same thing as you did with the order number and invoice number Ewout?

  29. Ewout
    Member
    Plugin Author

    Posted 1 year ago #

    Hi RJWJ,
    You can find the answer to your question a few posts up:

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce PDF Invoices & Packing Slips
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.