Thread Starter
xt
(@xueting)
In addition, how can I reset my invoice sequential unique identifier number daily? Because there is only an option to reset the number yearly. Do I need to edit coding scheme?
Thank you.
Plugin Contributor
Ewout
(@pomegranate)
Hello @xueting
These are not default fields from our plugin, I suspect they’re being added by third party plugins or that you’re possibly using another plugin. Could you post a screenshot of what you are referring to (you can use imgbb.com if you need somewhere to upload the image).
Thread Starter
xt
(@xueting)
Hello Ewout,
Thank you for your fast response.
The problem has been solved by removing third party plugin. However, I am trying to reset the invoice number daily. I found the following code snippet:
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 );
}
}
How do I change the code snippet to make it reset the invoice number daily? I changed every word ‘monthly’ to ‘daily’ but it seems like it is not the correct way…
Plugin Contributor
kluver
(@kluver)
Hi @xueting,
The following code snippet should reset the invoice number daily:
add_action( 'wpo_wcpdf_before_sequential_number_increment', 'wpo_wcpdf_reset_invoice_number_daily', 10, 3 );
function wpo_wcpdf_reset_invoice_number_daily( $number_store, $order_id, $date ) {
if ( $number_store->store_name == 'invoice_number' ) {
$current_day = date('j');
$last_number_day = $number_store->get_last_date('j');
// check if we need to reset
if ( $current_day != $last_number_day ) {
$number_store->set_next( 1 );
}
}
}
This code snippet should be added to the functions.php of your child theme or via a plugin like Code Snippets. If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters
Thread Starter
xt
(@xueting)
Hi kluver,
Thank you for the help, I have solved my problem now 🙂