-
-
Save mikejolley/22b7cef11cd2d4660d87bf8ea295ad13 to your computer and use it in GitHub Desktop.
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
/** | |
* Get order VAT Number data in one object/array. | |
* | |
* @param WC_Order $order The order object. | |
* @return object | |
*/ | |
protected static function get_order_vat_data( $order ) { | |
if ( version_compare( WC_VERSION, '2.7', '<' ) ) { | |
return (object) array( | |
'vat_number' => get_post_meta( $order->id, '_vat_number', true ), | |
'valid' => 'true' === get_post_meta( $order->id, '_vat_number_is_valid', true ), | |
'validated' => 'true' === get_post_meta( $order->id, '_vat_number_is_validated', true ), | |
'billing_country' => $order->billing_country, | |
'ip_address' => get_post_meta( $order->id, '_customer_ip_address', true ), | |
'ip_country' => get_post_meta( $order->id, '_customer_ip_country', true ), | |
'self_declared' => 'true' === get_post_meta( $order->id, '_customer_self_declared_country', true ), | |
); | |
} else { | |
return (object) array( | |
'vat_number' => $order->get_meta( '_vat_number', true ), | |
'valid' => wc_string_to_bool( $order->get_meta( '_vat_number_is_valid', true ) ), | |
'validated' => wc_string_to_bool( $order->get_meta( '_vat_number_is_validated', true ) ), | |
'billing_country' => $order->get_billing_country(), | |
'ip_address' => $order->get_customer_ip_address(), | |
'ip_country' => $order->get_meta( '_customer_ip_country', true ), | |
'self_declared' => wc_string_to_bool( $order->get_meta( '_customer_self_declared_country', true ) ), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment