Hi @bellabacinl
Yes, it is possible to change the Next Invoice Number using the below filter:
<?php
/**
* WCDN Invoice Number Reset
*
* Paste this code into your theme's functions.php file.
* Remove this code once the invoice number has been reset.
*
* HOW TO USE:
* 1. Set the value of WCDN_RESET_INVOICE_NUMBER below to your desired next invoice number
* 2. Paste this code into functions.php and save
* 3. Visit any page on your site (or WP admin)
* 4. Check WCDN settings to verify the new number
* 5. REMOVE this code from functions.php
*/
define( 'WCDN_RESET_INVOICE_NUMBER', 1 ); // 👈 Set your desired next invoice number here
add_action( 'init', function() {
// Run only once, not on every page load
$done_key = 'wcdn_invoice_reset_done_' . WCDN_RESET_INVOICE_NUMBER;
if ( get_option( $done_key ) ) {
return;
}
$next = (int) WCDN_RESET_INVOICE_NUMBER;
if ( $next < 1 ) {
return;
}
$counter_value = $next - 1;
update_option( 'wcdn_invoice_number_counter', $counter_value, false );
// Clear preview cache
delete_transient( 'wcdn_preview_data' );
// Mark as done so this does not run again
update_option( $done_key, 1, false );
// Show admin notice to confirm the reset
add_action( 'admin_notices', function() use ( $next ) {
if ( ! current_user_can( 'manage_options' ) ) return;
echo '<div class="notice notice-success is-dismissible"><p>';
echo '<strong>WCDN:</strong> Invoice number successfully reset. Next invoice number: <strong>' . esc_html( $next ) . '</strong>. You can now remove this code from functions.php.';
echo '</p></div>';
});
}, 5 );
You can add this filter code via Code Snippets plugin.
Please note that once the data has been reset, the custom snippet should be removed from the site to prevent it from running unnecessarily in the future.
Please check this on your end and let us know if you need any further assistance.