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 );
}
}