• Resolved completegraphics

    (@completegraphics)


    Is there a way to replace the woocommerce order number with the plugins invoice number?
    So i can continue to use the invoicing with an external invoicing software (Xero) so all the numbers match up and are sequential?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor alexmigf

    (@alexmigf)

    Hi,

    How Xero communicates with WooCommerce? Which third party plugin are you using to integrate both?

    • This reply was modified 3 years, 4 months ago by alexmigf.
    Thread Starter completegraphics

    (@completegraphics)

    Thanks for the reply,

    Im using the Xero from woocommerce (https://docs.woocommerce.com/document/xero/)

    i found this from an old thread

    add_filter('woocommerce_xero_invoice_invoice_number','wpo_wcpdf_xero_invoice_number',10,2);
    function wpo_wcpdf_xero_invoice_number( $invoice_number, $xero_invoice ) {
    	if ( !empty( $xero_invoice->order ) && $pdf_invoice = wcpdf_get_invoice( $xero_invoice->order, true ) ) {
    		if ( $pdf_invoice_number = $pdf_invoice->get_number() ) {
    			$invoice_number = $pdf_invoice_number->get_formatted();
    		}
    	}
    	return $invoice_number;
    }

    But it didn’t work for me.

    All it needs to do is replace the woocommerce default order number to the invoice number and it should work.

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @completegraphics,

    Please try this code snippet instead:

    add_filter('woocommerce_xero_invoice_invoice_number','wpo_wcpdf_xero_invoice_number',10,2);
    function wpo_wcpdf_xero_invoice_number( $invoice_number, $xero_invoice ) {
    	$order = $xero_invoice->get_order();
    	if ( !empty( $order ) && $pdf_invoice = wcpdf_get_invoice( $order, true ) ) {
    		if ( $pdf_invoice_number = $pdf_invoice->get_number() ) {
    			$invoice_number = $pdf_invoice_number->get_formatted();
    		}
    	}
    	return $invoice_number;
    }

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

    Note that we can’t test it ourselves, as we don’t have this plugin to do it, so my recommendation is that you try it on a test site first. If you need more help with this, we can offer it as part of our premium support. If this is the case, please write to us at [email protected].

    Let us know the results if you test it! ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Replace woocommerce order number with invoice number’ is closed to new replies.