• Resolved michaldybczak

    (@michaldybczak)


    Plugin creates consequential numbers based on creation of PDF not based on woommerce number of order and it creates many problems.

    – If from some reason I don’t create a PDF (because I already have invoice from different system) and skip to the next customer, he/she has a number smaller then it should be. In time those things add up and it leads to great difference between number on PDF and real order number.

    – Some orders are on hold (waiting for payment), others are in realization quickly so the order we process them is not the same they where placed by the customers. Because number is created by PDF creation and not checked with the oder number, again we have strong differences.

    Is there any way to link those two?

    https://www.ads-software.com/plugins/woocommerce-pdf-invoices-packing-slips/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hello Michael,
    The internal PDF invoice number is made for one single purpose, which is that it always to be sequential (i.e. leaving no gaps in the numbers). This is EU law.
    The only way to reliably accomplish this is to generate the number upon creation of the invoice (PDF). If the invoice number would be linked to either the order in which the orders are placed (remember, not all orders will be finished in most webshops), or the woocommerce order number, this would always leave gaps. For this reason, the PDF invoice number operates completely separate from the WooCommerce order number.

    However, if you do not have to abide to this EU law, you can choose the option “WooCommerce Order Number” in the PDF invoice settings panel, and the invoice will have the order number instead of the sequential invoice number. Any ‘link’ between the two numbers is not possible without breaking the sequential character of the system.

    There’s another option, if you have two invoice systems, you can control the ‘next invoice’ number from the settings panel. This way you can skip several invoice numbers when they have already been generated with the other system.

    So the invoice number is not ‘wrong’, and if you want to use the woocommerce order number that’s an option in the settings panel.

    Thread Starter michaldybczak

    (@michaldybczak)

    Thanks for clarification :).

    Invoices from your program don’t meet invoice requirements from my country (Poland) so I use them merely as a printed sum up of an order, so the setting “woocommerce order number” will be perfect then!

    Once again, thanks for the full info :).

    Steve

    (@steveholland)

    I can’t find the “WooCommerce Order Number” setting. Where is it?

    I am looking in WooCommerce > PDF Invoices and in the three tabs.

    Thread Starter michaldybczak

    (@michaldybczak)

    Weird. I could have sworn I saw this in woocommerce settings or near by but now when you mentioned it, I can’t find it either. Maybe they changed it in newer versions?

    Steve

    (@steveholland)

    Is it possible you just need to leave the “next invoice number” box blank and it will not just sync the number automatically?

    Plugin Contributor Ewout

    (@pomegranate)

    Hello Steve,
    There’s several approaches to solving this.

    1a) The simplest solution is indeed to leave the “Display built-in sequential invoice number” unchecked. It will then not print any invoice number in the PDF at all and just show the order number.
    1b) If you want it to say “Invoice Number” instead of “Order Number”, you’ll have to edit/customize the template (following instructions from the template settings page) and simply rename the label.
    2) If you want it display the same number twice, once as “Order Number” and once as Invoice number (formatted according to the settings), you can add the following code to your theme’s functions.php:

    /**
     * Format order number with invoice number settings
     */
    add_filter( 'wpo_wcpdf_invoice_number', 'wpo_wcpdf_format_invoice_number', 20, 4 );
    function wpo_wcpdf_format_invoice_number( $invoice_number, $order_number, $order_id, $order_date ) {
    	// We want to use the order number as invoice number!
    	$invoice_number = ltrim($order_number, '#');
    
    	// get format settings
    	$template_settings = get_option('wpo_wcpdf_template_settings');
    
    	$formats['prefix'] = isset($template_settings['invoice_number_formatting_prefix'])?$template_settings['invoice_number_formatting_prefix']:'';
    	$formats['suffix'] = isset($template_settings['invoice_number_formatting_suffix'])?$template_settings['invoice_number_formatting_suffix']:'';
    	$formats['padding'] = isset($template_settings['invoice_number_formatting_padding'])?$template_settings['invoice_number_formatting_padding']:'';
    
    	// Replacements
    	$order_year = date_i18n( 'Y', strtotime( $order_date ) );
    	$order_month = date_i18n( 'm', strtotime( $order_date ) );
    
    	foreach ($formats as $key => $value) {
    		$value = str_replace('[order_year]', $order_year, $value);
    		$value = str_replace('[order_month]', $order_month, $value);
    		$formats[$key] = $value;
    	}
    
    	// Padding - minimum of 3 for safety
    	if ( ctype_digit( (string)$formats['padding'] ) && $formats['padding'] > 3 ) {
    		$invoice_number = sprintf('%0'.$formats['padding'].'d', $invoice_number);
    	}
    
    	$formatted_invoice_number = $formats['prefix'] . $invoice_number . $formats['suffix'] ;
    
    	return $formatted_invoice_number;
    }

    Good luck!
    Ewout

    Steve

    (@steveholland)

    I think you may have misunderstood.

    My order numbers and invoice numbers are out of sync.

    For example, order #1176 has an invoice number #1104

    Why can’t the invoice number be the same as the order number in all cases? See this screenshot: https://docs.google.com/file/d/0B_ynoyoLwXgTNjFUckNFM1I1Ykk/edit?usp=drivesdk

    Why is the invoice number different to the order number? This is just confusing.

    Plugin Contributor Ewout

    (@pomegranate)

    This is because in many countries (all of the EU for example!) invoice numbers cannot have gaps in them – the need to be numbered sequentially. There’s a plugin to have the order numbers numbered sequentially, WooCommerce Sequential Order Numbers. However, this is often not enough, because cancelled and failed orders still get an order number. Enter separate invoice numbers. Invoice numbers are only created when an invoice is created, and always sequential. This is extremely important for European shops.

    That said, option 2) will display the same number in both columns.

    Ewout

    Steve

    (@steveholland)

    Great, thank-you. Perhaps this piece of code could be added to the FAQs section?

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Wrong number – not synchronized with the woocommerce’ is closed to new replies.