• Hi!

    Wonderful plugin, but I have 2 questions:

    1) How to remove all of the invoices currently generated. I need to start “from scratch” with invoice number 1. I did some testing and now I don’t have invoice numbers sorted in any way, I need to reset that. I already tried overwrite the number in the Settings, but this way all generated invoices are still there.

    2) Is there any way to change the “Invoice date” to “Order date”? As I am generating invoices for previous orders (which are done long time ago), the system shows todays date for the invoice. Should be the same date as order.

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor kluver

    (@kluver)

    Hi @brnveebilahendused,

    If you go to your WordPress Dashboard > WooCommerce > PDF Invoices > Status you can click ‘Remove Temporary Files’. This will remove all the uploads to wp-content/uploads/wpo_wcpdf/attachments/

    If you go to WordPress Dashboard > WooCommerce > PDF Invoices > Documents you can set the ‘Next Invoice Number’ to 1.

    To change the Invoice date to the Order date I would recommend to create a custom template and replace the part where the invoice date is called. You will have to call the order_date custom field.

    You can find more information here:
    Creating a custom template
    Displaying a custom field

    I hope this helps you in the right direction!

    With kind regards,

    Michael

    Thread Starter BRNVeebilahendused

    (@brnveebilahendused)

    Hi!

    Thanks, the invoice now displays order date as invoice date.

    But I could not reset all invoice numbers so I could start from 0001 again. Deleting temporary files did not help ??

    Plugin Contributor Ewout

    (@pomegranate)

    Hi @brnveebilahendused,
    Indeed, removing the temporary files or resetting the ‘next invoice number’ will not affect invoices that you have already created. This is data that is stored in the database, per order.

    Now there are two ways to do this, a simple/fool-proof method and an advanced, more dangerous method.

    1) Simple method
    If this is not for hundreds of orders, you can remove the invoice numbers (and dates manually) by opening the order in the WooCommerce backend, clicking the edit button in the “PDF Invoice Data” section and remove the number and date. Then save the order and it’s reset. Rinse and repeat.

    2) Advanced method
    This is more difficult and also more dangerous because you’re going to directly modify the database with a script. Here’s the script:

    
    add_action( 'init', 'wpo_wcpdf_remove_invoice_numbers');
    function wpo_wcpdf_remove_invoice_numbers() {
        if ( isset( $_GET['wcpdf_remove_invoice_numbers'] ) ) {
            $args = array(
                //'status'                => array('processing','completed'),
                'return'                => 'ids',
                'type'                  => 'shop_order',
                'limit'                 => -1,
                //'date_created'  => '2017-03-22...2017-11-22',
            );
            $order_ids = wc_get_orders( $args );
            foreach ($order_ids as $order_id) {
                $order = wc_get_order( $order_id );
                $order->delete_meta_data( '_wcpdf_invoice_number' );
                $order->delete_meta_data( '_wcpdf_invoice_number_data' );
                $order->delete_meta_data( '_wcpdf_invoice_exists' );
                $order->delete_meta_data( '_wcpdf_formatted_invoice_number' );
                $order->save();
        }
            wp_die(sprintf('Invoice numbers removed from %s orders!', count($order_ids)));
        }
    }
    

    Instructions:

    • Install the script on your site (read this if you haven’t worked with actions/filters before!)
    • Open a url on your site and add ‘wcpdf_remove_invoice_numbers=true’ to it. For example yoursite.com/wp-admin/edit.php?post_type=shop_order&wcpdf_remove_invoice_numbers=true
    • You should see a page “Invoice numbers removed from ### orders!” (may take some time to load if you have many orders in your shop).
    • REMOVE the script, to prevent other people from executing it
    • You can then create the invoices again (either in bulk or per order).

    additional tweaks:

    • If you have many orders in your shop but only want to remove the order numbers for a specific date range, you can uncomment the date_created line in the code snippet and alter the date rande (format: YYYY-MM-DD). This also helps if there’s too many orders to process in one request
    • Same for the order status.

    I recommend making a site backup before doing this!
    Hope that helps!

    Ewout

    Thread Starter BRNVeebilahendused

    (@brnveebilahendused)

    Hi!

    Thanks a lot, this helped!

    Is there any way to automatically generate PDF invoice after someone makes new order? At the moment, I must go into admin and press on “PDF invoice” in order to generate invoice.

    Plugin Contributor kluver

    (@kluver)

    Hi @brnveebilahendused,

    Yes if you go to your WordPress Dashboard > WooCommerce > PDF Invoice > Documents > Invoice you can select to which WooCommerce email you would like to attach the invoice to. For instance by selecting ‘Completed order’ it will automatically create an invoice and attach it to the Completed order email.

    I hope this answers your question.
    With kind regards,

    Michael

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Reset invoice numbers completely / Date issue’ is closed to new replies.