Last active
December 18, 2015 15:19
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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