diff --git a/retailcrm/job/sync.php b/retailcrm/job/sync.php index 9a07559..8378a1e 100644 --- a/retailcrm/job/sync.php +++ b/retailcrm/job/sync.php @@ -293,33 +293,6 @@ if ($history->isSuccessful() && count($history->history) > 0) { } else { $orderToUpdate = new Order((int) $order['externalId']); - /* - * check status - */ - if(!empty($order['status'])) { - $stype = $order['status']; - - if ($statuses[$stype] != null) { - if ($statuses[$stype] != $orderToUpdate->current_state) { - Db::getInstance()->execute(' - INSERT INTO `' . _DB_PREFIX_ . 'order_history` (`id_employee`, `id_order`, `id_order_state`, `date_add`) - VALUES ( - 0, - ' . $orderToUpdate->id . ', - ' . $statuses[$stype] . ', - "' . date('Y-m-d H:i:s') . '" - ) - '); - - Db::getInstance()->execute(' - UPDATE `' . _DB_PREFIX_ . 'orders` - SET `current_state` = \'' . $statuses[$stype] . '\' - WHERE `id_order` = ' . (int)$order['externalId'] - ); - } - } - } - /* * check delivery type */ @@ -574,6 +547,34 @@ if ($history->isSuccessful() && count($history->history) > 0) { unset($ItemDiscount); } + + /* + * check status + */ + if(!empty($order['status'])) { + $stype = $order['status']; + + if ($statuses[$stype] != null) { + if ($statuses[$stype] != $orderToUpdate->current_state) { + Db::getInstance()->execute(' + INSERT INTO `' . _DB_PREFIX_ . 'order_history` (`id_employee`, `id_order`, `id_order_state`, `date_add`) + VALUES ( + 0, + ' . $orderToUpdate->id . ', + ' . $statuses[$stype] . ', + "' . date('Y-m-d H:i:s') . '" + ) + '); + + Db::getInstance()->execute(' + UPDATE `' . _DB_PREFIX_ . 'orders` + SET `current_state` = \'' . $statuses[$stype] . '\' + WHERE `id_order` = ' . (int)$order['externalId'] + ); + } + } + } + } } /* diff --git a/retailcrm/retailcrm.php b/retailcrm/retailcrm.php index 99e02bd..7d1497e 100644 --- a/retailcrm/retailcrm.php +++ b/retailcrm/retailcrm.php @@ -395,8 +395,8 @@ class RetailCRM extends Module $address = array_shift($addressCollection); if ($address instanceof Address) { - $phone = is_null($address->phone) - ? is_null($address->phone_mobile) ? '' : $address->phone_mobile + $phone = empty($address->phone) + ? empty($address->phone_mobile) ? '' : $address->phone_mobile : $address->phone; $postcode = $address->postcode;