Automattic\WooCommerce\Blocks\StoreApi\Utilities
OrderController::sync_customer_data_with_order() public WC 1.0
Copies order data to customer object (not the session), so values persist for future checkouts.
{} Это метод класса: OrderController{}
Хуков нет.
Возвращает
Null. Ничего.
Использование
$OrderController = new OrderController(); $OrderController->sync_customer_data_with_order( \WC_Order $order );
- \WC_Order $order (обязательный)
- -
Код OrderController::sync_customer_data_with_order() OrderController::sync customer data with order WC 5.0.0
public function sync_customer_data_with_order( \WC_Order $order ) {
if ( $order->get_customer_id() ) {
$customer = new \WC_Customer( $order->get_customer_id() );
$customer->set_props(
[
'billing_first_name' => $order->get_billing_first_name(),
'billing_last_name' => $order->get_billing_last_name(),
'billing_company' => $order->get_billing_company(),
'billing_address_1' => $order->get_billing_address_1(),
'billing_address_2' => $order->get_billing_address_2(),
'billing_city' => $order->get_billing_city(),
'billing_state' => $order->get_billing_state(),
'billing_postcode' => $order->get_billing_postcode(),
'billing_country' => $order->get_billing_country(),
'billing_email' => $order->get_billing_email(),
'billing_phone' => $order->get_billing_phone(),
'shipping_first_name' => $order->get_shipping_first_name(),
'shipping_last_name' => $order->get_shipping_last_name(),
'shipping_company' => $order->get_shipping_company(),
'shipping_address_1' => $order->get_shipping_address_1(),
'shipping_address_2' => $order->get_shipping_address_2(),
'shipping_city' => $order->get_shipping_city(),
'shipping_state' => $order->get_shipping_state(),
'shipping_postcode' => $order->get_shipping_postcode(),
'shipping_country' => $order->get_shipping_country(),
]
);
$customer->save();
};
}