From 41ad7bbbce9265f040c7a6835bf7c563d89be305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B0=D0=B2=D0=B5=D0=BB?= Date: Mon, 1 Jun 2020 09:38:17 +0300 Subject: [PATCH] fixes & more fields for sync --- src/include/class-wc-retailcrm-history.php | 27 ++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/include/class-wc-retailcrm-history.php b/src/include/class-wc-retailcrm-history.php index 342103b..729b037 100644 --- a/src/include/class-wc-retailcrm-history.php +++ b/src/include/class-wc-retailcrm-history.php @@ -352,6 +352,7 @@ if ( ! class_exists( 'WC_Retailcrm_History' ) ) : $wc_order->set_shipping_last_name($order['lastName']); } +<<<<<<< HEAD if (isset($order['phone'])) { $wc_order->set_billing_phone($order['phone']); } @@ -360,6 +361,8 @@ if ( ! class_exists( 'WC_Retailcrm_History' ) ) : $wc_order->set_billing_email($order['email']); } +======= +>>>>>>> fixes & more fields for sync if (array_key_exists('items', $order)) { foreach ($order['items'] as $key => $item) { @@ -485,17 +488,19 @@ if ( ! class_exists( 'WC_Retailcrm_History' ) ) : $wc_order->save(); - $checkNewItem = false; - foreach ($order['items'] as $item) { - if (!empty($item['externalIds'])) { - continue; - } else { - $checkNewItem = true; + if (isset($order['items'])) { + $checkNewItem = false; + foreach ($order['items'] as $item) { + if (!empty($item['externalIds'])) { + continue; + } else { + $checkNewItem = true; + } } - } - if ($checkNewItem == true) { - $this->editOrder($this->retailcrm_settings, $wc_order, $order,'update'); + if ($checkNewItem == true) { + $this->editOrder($this->retailcrm_settings, $wc_order, $order,'update'); + } } return $wc_order->get_id(); @@ -581,6 +586,10 @@ if ( ! class_exists( 'WC_Retailcrm_History' ) ) : return false; } + if (isset($order['managerComment']) && !empty($order['managerComment'])) { + $wc_order->add_order_note($order['managerComment'], 0, false); + } + if (isset($order['customer']['type']) && $order['customer']['type'] == 'customer_corporate' && !empty($order['customer']['mainCompany'])