• Resolved medtr

    (@medtr)


    Hi,

    Thank you for this great plugin.

    Is there any code snippet to reset the invoice counter every start of month.
    I use this format:[invoice_year][invoice_month]

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

    (@pomegranate)

    Yes, that’s possible. The most reliable method for this is to keep the sequence for each month in separate database tables, you can use this code snippet:

    add_filter( 'wpo_wcpdf_invoice_number_store_name', function( $number_store_name, $store_base_name, $date, $method, $document ) {
    	$year  = $date->date_i18n( 'Y' );
    	$month = $date->date_i18n( 'm' );
    	return "{$store_base_name}_{$month}_{$year}";
    }, 10, 5 );

    There’s an alternative method here, but it’s more prone to errors because if for some reason you need to create an invoice for last month (or next month), this will trigger a reset each time you switch between months.

    Thread Starter medtr

    (@medtr)

    it works great!
    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Reset invoice counter every month’ is closed to new replies.