From 18571bfea73c1feae756db60d7bf08f404a5fa16 Mon Sep 17 00:00:00 2001 From: Pavel Date: Thu, 13 Feb 2020 13:35:26 +0300 Subject: [PATCH] extract customer phone and email from order for guests --- src/include/class-wc-retailcrm-customers.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/include/class-wc-retailcrm-customers.php b/src/include/class-wc-retailcrm-customers.php index b6b6894..c623bc6 100644 --- a/src/include/class-wc-retailcrm-customers.php +++ b/src/include/class-wc-retailcrm-customers.php @@ -269,6 +269,8 @@ if (!class_exists('WC_Retailcrm_Customers')) : $createdAt = $customer->get_date_created(); $firstName = $customer->get_first_name(); $lastName = $customer->get_last_name(); + $billingPhone = $customer->get_billing_phone(); + $email = $customer->get_email(); if (empty($firstName) && empty($lastName) && $order instanceof WC_Order) { $firstName = $order->get_billing_first_name(); @@ -282,6 +284,14 @@ if (!class_exists('WC_Retailcrm_Customers')) : if (empty($firstName)) { $firstName = $customer->get_username(); } + + if (empty($email)) { + $email = $order->get_billing_email(); + } + + if (empty($billingPhone)) { + $order->get_billing_phone(); + } } if (empty($createdAt)) { @@ -292,7 +302,7 @@ if (!class_exists('WC_Retailcrm_Customers')) : 'createdAt' => $createdAt->date('Y-m-d H:i:s'), 'firstName' => $firstName, 'lastName' => $lastName, - 'email' => $customer->get_email(), + 'email' => $email, 'address' => $this->customer_address->build($customer, $order)->get_data() ); @@ -300,7 +310,7 @@ if (!class_exists('WC_Retailcrm_Customers')) : $data_customer['externalId'] = $customer->get_id(); } - if ($customer->get_billing_phone()) { + if (!empty($billingPhone)) { $data_customer['phones'][] = array( 'number' => $customer->get_billing_phone() );