• Resolved janbong

    (@janbong)


    Hi there,

    May I know is there a way I can reset my invoice number to a new month every month?

    For example:
    From OS-CS2005-0471 to OS-CS2006-0001

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor alexmigf

    (@alexmigf)

    Hello @janbong

    If you set the the prefix with the placeholders for year and month correctly, the number can be reset with this 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 );
        }
    }
    Thread Starter janbong

    (@janbong)

    Hi there,

    Thanks. Let us try on the following month and see if it will reset.

    phirefly

    (@phirefly)

    Hi @alexmigf
    I’m looking for similar functionality “Reset invoice number annually”.

    Is the code snippet above future-proof?

    Thanks

    Plugin Contributor alexmigf

    (@alexmigf)

    Hello @phirefly

    Annually is already an option inside de plugin, under PDF Invoices > Documents > Invoice:

    Captura-de-ecra-2020-06-03-a-s-13-42-57

    • This reply was modified 6 years ago by alexmigf.
    phirefly

    (@phirefly)

    Apologies @alexmigf ; typo – I meant monthly. #Doh!

    I’m looking for similar functionality “Reset invoice number monthly”.

    Is the code snippet above future-proof?

    Thanks

    Plugin Contributor alexmigf

    (@alexmigf)

    phirefly

    (@phirefly)

    Thanks @alexmigf – good to know that is still working.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Reset Invoice Number Monthly’ is closed to new replies.