• Resolved jdaldana

    (@jdaldana)


    Hi,

    This plug-in is working fine for us right now and its great!

    I see an option to toggle “Reset invoice number yearly” but I would like to know if there’s an option to reset the invoice monthly? That way we can track how many invoices/sales we generate each month in an easier way.

    I also tried adding prefixes and suffixes but it doesn’t seem to be working. I added a padding number (4) as well but the invoice number (i.e., 27) did not change to 0027.

    Any suggestions/comments/help is appreciated.
    Thanks in advance!

    • This topic was modified 7 years, 4 months ago by jdaldana. Reason: Updated title; added some questions
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hi! Answering your last question first:
    The prefix and suffix settings only apply to new orders, if you have already created an invoice and want to reformat the number, you have to ‘edit’ the invoice number in the order details – not actually change anything, just click the edit button and save the order. That way the formatted invoice number will get updated.

    There is currently no built in way to reset the invoice number monthly, unfortunately.

    Let me know if you have any other questions!

    Ewout

    Plugin Contributor Ewout

    (@pomegranate)

    For anyone else looking to reset the invoice number monthly, with the latest version this is possible with the following code snippet:

    
    do_action( 'wpo_wcpdf_before_sequential_number_increment', 'wpo_wcpdf_reset_invoice_number_monthly', 10, 3 );
    function wpo_wcpdf_reset_invoice_number_monthly( $number_store, $order_id, $date ) {
        $current_month = date('n');
        $last_number_month = $number_store->get_last_date('n');
        // check if we need to reset
        if ( $current_month != $last_number_month ) {
            $number_store->set_next( 1 );
        }
    }
    

    If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters

    Hope that helps!
    Ewout

    Plugin Contributor Ewout

    (@pomegranate)

    We found there’s a small error with the above code (using do_action instead of add_action), the correct filter is:

    
    add_action( 'wpo_wcpdf_before_sequential_number_increment', 'wpo_wcpdf_reset_invoice_number_monthly', 10, 3 );
    function wpo_wcpdf_reset_invoice_number_monthly( $number_store, $order_id, $date ) {
        $current_month = date('n');
        $last_number_month = $number_store->get_last_date('n');
        // check if we need to reset
        if ( $current_month != $last_number_month ) {
            $number_store->set_next( 1 );
        }
    }
    
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Reset Invoice Number Monthly’ is closed to new replies.