From 155a2d571637888e4ef368f000ffa42d5fbba41b Mon Sep 17 00:00:00 2001 From: max-baranikov Date: Mon, 28 Sep 2020 13:38:23 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=A4=D0=98=D0=9E=20?= =?UTF-8?q?=D0=B8=D0=B7=20=D0=BF=D0=BB=D0=B0=D1=82=D0=B5=D0=B6=D0=BD=D0=BE?= =?UTF-8?q?=D0=B3=D0=BE=20=D0=B0=D0=B4=D1=80=D0=B5=D1=81=D0=B0,=20=D0=B2?= =?UTF-8?q?=20=D1=81=D0=BB=D1=83=D1=87=D0=B0=D0=B5,=20=D0=B5=D1=81=D0=BB?= =?UTF-8?q?=D0=B8=20=D0=A4=D0=98=D0=9E=20=D0=B2=20=D0=B0=D0=B4=D1=80=D0=B5?= =?UTF-8?q?=D1=81=D0=B5=20=D0=B4=D0=BE=D1=81=D1=82=D0=B0=D0=B2=D0=BA=D0=B8?= =?UTF-8?q?=20=D0=BF=D1=83=D1=81=D1=82=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/include/class-wc-retailcrm-orders.php | 13 +++++++++++-- src/include/order/class-wc-retailcrm-order.php | 13 +++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/include/class-wc-retailcrm-orders.php b/src/include/class-wc-retailcrm-orders.php index 0f15610..fb11e8c 100644 --- a/src/include/class-wc-retailcrm-orders.php +++ b/src/include/class-wc-retailcrm-orders.php @@ -189,8 +189,17 @@ if ( ! class_exists( 'WC_Retailcrm_Orders' ) ) : } if ($update && $customerWasChanged) { - $this->order['firstName'] = $wcOrder->get_shipping_first_name(); - $this->order['lastName'] = $wcOrder->get_shipping_last_name(); + $firstName = $wcOrder->get_shipping_first_name(); + $lastName = $wcOrder->get_shipping_last_name(); + + if(empty($firstName) && empty($lastName)) + { + $firstName = $wcOrder->get_billing_first_name(); + $lastName = $wcOrder->get_billing_last_name(); + } + + $this->order['firstName'] = $firstName; + $this->order['lastName'] = $lastName; } return true; diff --git a/src/include/order/class-wc-retailcrm-order.php b/src/include/order/class-wc-retailcrm-order.php index 2f82450..2c9e083 100644 --- a/src/include/order/class-wc-retailcrm-order.php +++ b/src/include/order/class-wc-retailcrm-order.php @@ -53,11 +53,20 @@ class WC_Retailcrm_Order extends WC_Retailcrm_Abstracts_Data */ public function build($order) { + $firstName = $order->get_shipping_first_name(); + $lastName = $order->get_shipping_last_name(); + + if(empty($firstName) && empty($lastName)) + { + $firstName = $order->get_billing_first_name(); + $lastName = $order->get_billing_last_name(); + } + $data = array( 'externalId' => $order->get_id(), 'createdAt' => $order->get_date_created()->date('Y-m-d H:i:s'), - 'firstName' => $order->get_shipping_first_name(), - 'lastName' => $order->get_shipping_last_name(), + 'firstName' => $firstName, + 'lastName' => $lastName, 'email' => $order->get_billing_email(), 'customerComment' => $order->get_customer_note(), 'phone' => $order->get_billing_phone(),