WC_API_Customers::add_customer_data()
Add customer data to orders
Method of the class: WC_API_Customers{}
No Hooks.
Return
Array
.
Usage
$WC_API_Customers = new WC_API_Customers(); $WC_API_Customers->add_customer_data( $order_data, $order );
- $order_data (required)
- -
- $order (required)
- -
Changelog
Since 2.1 | Introduced. |
WC_API_Customers::add_customer_data() WC API Customers::add customer data code WC 7.7.0
public function add_customer_data( $order_data, $order ) { if ( 0 == $order->get_user_id() ) { // add customer data from order $order_data['customer'] = array( 'id' => 0, 'email' => $order->get_billing_email(), 'first_name' => $order->get_billing_first_name(), 'last_name' => $order->get_billing_last_name(), 'billing_address' => array( 'first_name' => $order->get_billing_first_name(), 'last_name' => $order->get_billing_last_name(), 'company' => $order->get_billing_company(), 'address_1' => $order->get_billing_address_1(), 'address_2' => $order->get_billing_address_2(), 'city' => $order->get_billing_city(), 'state' => $order->get_billing_state(), 'postcode' => $order->get_billing_postcode(), 'country' => $order->get_billing_country(), 'email' => $order->get_billing_email(), 'phone' => $order->get_billing_phone(), ), 'shipping_address' => array( 'first_name' => $order->get_shipping_first_name(), 'last_name' => $order->get_shipping_last_name(), 'company' => $order->get_shipping_company(), 'address_1' => $order->get_shipping_address_1(), 'address_2' => $order->get_shipping_address_2(), 'city' => $order->get_shipping_city(), 'state' => $order->get_shipping_state(), 'postcode' => $order->get_shipping_postcode(), 'country' => $order->get_shipping_country(), ), ); } else { $order_data['customer'] = current( $this->get_customer( $order->get_user_id() ) ); } return $order_data; }