• Resolved Daniel Kozina

    (@webcraftersstudio)


    Hello,

    Is possible to generate a different invoice number format for the company and personal customers?

    For personal customers, it should be: OV/2/11/2020
    For companies, it should be: FV/2/11/2020

    Already I have set the companies variant so my clients have invoices number like FV/2/11/2020 but what I can do with personal customers?

    Daniel

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

    (@pomegranate)

    Hi Daniel,
    To do that you need a small code snippet. Assuming you distinguish personal customers from companies by the company name field, you can use the following:

    
    add_filter('wpo_wcpdf_document_number_settings','wpo_wcpdf_document_number_variable_prefix',10,2);
    function wpo_wcpdf_document_number_variable_prefix( $number_settings, $document ) {
    	if (!empty($document->order) && $document->get_type() == 'invoice') {
    		$billing_company = $document->order->get_billing_company();
    		if (empty($billing_company)) { // private customer
    			$number_settings['prefix'] = "OV/";
    		}
    	}
    	return $number_settings;
    }
    

    This will set the prefix to OV/ for any customer that doesn’t enter their company name.

    You can use other requirements too, I just used the company name as an example here because it’s the only official WooCommerce field that makes that distinction.

    If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters

    Thread Starter Daniel Kozina

    (@webcraftersstudio)

    Hello,

    Thank you! it’s working properly!

    BUT ?? – The number is still the same. I mean some business client bought something and his invoice number is FV/10/11/2020 but after him some other customer bought something and his invoice number is OV/11/11/2020 so the enumeration is the same. We can do different numeration for business and personal customers?

    Best regards,
    Daniel

    Plugin Contributor Ewout

    (@pomegranate)

    Having two different number sequences is a lot harder, unfortunately we can’t provide that as support for the free version. This will require custom code to maintain the different sequences.

    Thread Starter Daniel Kozina

    (@webcraftersstudio)

    Thank you for help, I understand it.

    Plugin Contributor Ewout

    (@pomegranate)

    An alternative solution that doesn’t require any coding would be to utilize the Professional extension. This comes with a separate document “Proforma Invoice” that you could rename (via the settings) and use that to send to your private customers and send the original invoice to the business customers. These documents use their own number sequences. That would still require a bit of custom code (making sure the customers get the right document automatically) but we can certainly provide that as part of plugin support. If you want more information about this, please send an email to [email protected]

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Different invoice number format for the company and personal customers’ is closed to new replies.