From ef796ebd756981e98a554ef0b883d284a24da22a Mon Sep 17 00:00:00 2001 From: Neur0toxine Date: Wed, 10 Jun 2020 12:13:51 +0300 Subject: [PATCH] sync more fields in the history --- CHANGELOG.md | 3 +++ VERSION | 2 +- src/include/class-wc-retailcrm-history.php | 27 +++++++++++++++++++++- src/readme.txt | 3 +++ src/retailcrm.php | 2 +- src/uninstall.php | 2 +- 6 files changed, 35 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba4af4f..d0f090a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2020-06-10 3.6.3 +* Улучшено обновление данных заказа по истории + ## 2020-04-13 3.6.2 * Исправлена ошибка, которая приводила к дублированию некоторых клиентов diff --git a/VERSION b/VERSION index b727628..4a788a0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.6.2 +3.6.3 diff --git a/src/include/class-wc-retailcrm-history.php b/src/include/class-wc-retailcrm-history.php index ff732ea..2101e2c 100644 --- a/src/include/class-wc-retailcrm-history.php +++ b/src/include/class-wc-retailcrm-history.php @@ -317,6 +317,7 @@ if ( ! class_exists( 'WC_Retailcrm_History' ) ) : * @param array $options * * @return bool + * @throws \WC_Data_Exception */ protected function orderUpdate($order, $options) { @@ -330,6 +331,30 @@ if ( ! class_exists( 'WC_Retailcrm_History' ) ) : $wc_order->update_status($options[$order['status']]); } + if (isset($order['customerComment'])) { + $wc_order->set_customer_note($order['customerComment']); + } + + if (isset($order['managerComment']) && !empty($order['managerComment'])) { + $wc_order->add_order_note($order['managerComment'], 0, false); + } + + if (isset($order['firstName'])) { + $wc_order->set_shipping_first_name($order['firstName']); + } + + if (isset($order['lastName'])) { + $wc_order->set_shipping_last_name($order['lastName']); + } + + if (isset($order['phone'])) { + $wc_order->set_billing_phone($order['phone']); + } + + if (isset($order['email'])) { + $wc_order->set_billing_email($order['email']); + } + if (array_key_exists('items', $order)) { foreach ($order['items'] as $key => $item) { @@ -519,7 +544,7 @@ if ( ! class_exists( 'WC_Retailcrm_History' ) ) : $args = array( 'status' => isset($options[$order['status']]) - ? isset($options[$order['status']]) + ? $options[$order['status']] : 'processing', 'customer_id' => isset($order['customer']['externalId']) ? $order['customer']['externalId'] diff --git a/src/readme.txt b/src/readme.txt index 622d1f3..3200728 100644 --- a/src/readme.txt +++ b/src/readme.txt @@ -45,6 +45,9 @@ API-ключ должен быть для отдельного магазина 2. В появившихся списках справочников настройте соответствие способов доставки и оплаты, а так же статусов заказов. Отметьте галочку "Выгружать остатки", если хотите выгружать остатки из Retailcrm в магазин (подробнее смотрите в описании). == Changelog == += 3.6.3 = +* Улучшено обновление данных заказа по истории + = 3.6.2 = * Исправлена ошибка, которая приводила к дублированию некоторых клиентов diff --git a/src/retailcrm.php b/src/retailcrm.php index a2e8a10..094ae23 100644 --- a/src/retailcrm.php +++ b/src/retailcrm.php @@ -1,6 +1,6 @@