WC_API_Customers::add_customer_data()publicWC 2.1

Add customer data to orders

Метод класса: WC_API_Customers{}

Хуков нет.

Возвращает

Массив.

Использование

$WC_API_Customers = new WC_API_Customers();
$WC_API_Customers->add_customer_data( $order_data, $order );
$order_data (обязательный)
-
$order (обязательный)
-

Список изменений

С версии 2.1 Введена.

Код WC_API_Customers::add_customer_data() WC 8.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;
}