Hello,
first go to the settings http://joxi.ru/kNZwU_3JTJBVU1nD3so and enable the option.
Second, remove all your existing invoices with custom IDs if you have such.
Third, when creating first invoice open advanced settings http://joxi.ru/itdwUxjKTJCgRls0GxY That way you started invoice counting from 1.
Next invoice will be created with ID of 2.
Let me know if you have other questions.
Thanks.
I had since done that, but when I create a new invoice ‘from another’ it does not increment. (I tried creating with an entirely new invoice and the increment worked fine so you prob just need to add the increment code to ‘invoice from another’ tool).
Thanks. We’ll look into it.
Hi, I just tested your plugin again and this bug has not been fixed. Custom ID’s do not increment if a new invoice is created from an existing template.
Hi, I had a quick look myself at the code and invoice_page_wpi_page_manage_invoice.php does not increment the custom_invoice_id if a new invoice is created from an existing invoice.
I altered the code as below to solve the problem so that copying from an existing invoice also increments custom_invoice_id. Hopefully this will help the developer to address the bug:
wpi_ui.php
static function page_manage_invoice_preprocess( $screen_id ) {
global $wpi_settings, $this_invoice, $wpdb, $template_used; //add $template_used
// a few lines lower down...
// New Invoice
if ( isset( $_REQUEST[ 'wpi' ][ 'new_invoice' ] ) && empty( $invoice_id_exists ) ) {
$this_invoice = new WPI_Invoice();
$this_invoice->create_new_invoice( "invoice_id={$_REQUEST[ 'wpi' ][ 'new_invoice' ]['invoice_id']}" );
$template_used = 0; //add $template_used = 0
// If we are copying from a template
if ( !empty( $_REQUEST[ 'wpi' ][ 'new_invoice' ][ 'template_copy' ] ) ) {
$this_invoice->load_template( "id={$_REQUEST[ 'wpi' ][ 'new_invoice' ]['template_copy']}" );
$template_used = 1; //add $template_used = 1
invoice_page_wpi_page_manage_invoice.php
if ((empty($custom_invoice_id) && $wpi_settings['increment_invoice_id'] == 'true') || $template_used = 1) { //add || $template_used = 1
Please use github pull requests for fixes like this.
We will look into it then. Thanks.
OK, I have never done anything like that before but will try.
Having studied code a little further there is a simple fix to make custom invoice IDs increment when copying from existing invoice.
In meta file /wp-invoice/core/ui/metabox/invoice_page_wpi_page_manage_invoice.php
Original code (~line 198):
if ((empty($custom_invoice_id) && $wpi_settings['increment_invoice_id'] == 'true'))
New Code:
if (((empty($custom_invoice_id) || empty($this_invoice['ID'])) && $wpi_settings['increment_invoice_id'] == 'true'))
Addition of: || empty($this_invoice['ID']
The idea is that this simply tests for the existence of an ID which is unset after a template is loaded by the last line of the load_template function from wpi_invoice.php:
unset($this->data['ID']);
_______
PS: Error in my original code from above:
code
I accidentally typo
|| $template_used = 1)
instead of
|| $template_used == 1)
in invoice_page_wpi_page_manage_invoice.php (meta file)