Skip to content

Instantly share code, notes, and snippets.

@rahul286
Last active December 18, 2015 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahul286/5803731 to your computer and use it in GitHub Desktop.
Save rahul286/5803731 to your computer and use it in GitHub Desktop.
Fix for woocommerce-xero extension. Original plugin depends on billing address. In our case, we have disabled billing/shipping address so first_name and last_name should be fetched from WordPress usermeta.
// construct XML
$xml = '';
$xml .= '<Invoices>';
$xml .= '<Invoice>';
$xml .= '<Type>ACCREC</Type>';
$xml .= '<Contact>';
if( $order->billing_first_name == ""){
$order->billing_first_name = get_usermeta($order->user_id,'first_name');
}
if( $order->billing_last_name == ""){
$order->billing_last_name = get_usermeta($order->user_id,'last_name');
}
// Company name will be used as main name if it exists
$xml .= '<InvoiceNumber>WC-' . ltrim( $order->get_order_number(), _x( '#', 'hash befor e order number', 'woocommerce' ) ) . '</InvoiceNumber>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment