From caf55f67ada2ec6ae884a1824e26b144ec99372f Mon Sep 17 00:00:00 2001 From: Daniel Weiser Date: Wed, 15 Jul 2020 12:28:02 +0300 Subject: [PATCH] refactoring --- .../catalog/model/extension/retailcrm/order.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/upload/catalog/model/extension/retailcrm/order.php b/src/upload/catalog/model/extension/retailcrm/order.php index f01a10c..2400fdb 100644 --- a/src/upload/catalog/model/extension/retailcrm/order.php +++ b/src/upload/catalog/model/extension/retailcrm/order.php @@ -48,16 +48,16 @@ class ModelExtensionRetailcrmOrder extends Model { if ($create) { $order = self::filterRecursive($order); $response = $retailcrmApiClient->ordersCreate($order); - if ($response->getStatusCode() === 400 && !empty($response->__get('errors')['customer.externalId'])) { + if (isset($response['errors']['customer.externalId'])) { $order['customer'] = $this->createCustomer($data); - $response = $retailcrmApiClient->ordersEdit($order); + $response = $retailcrmApiClient->ordersCreate($order); } } else { $order_payment = reset($order['payments']); unset($order['payments']); $order = self::filterRecursive($order); $response = $retailcrmApiClient->ordersEdit($order); - if ($response->getStatusCode() === 400 && !empty($response->__get('errors')['customer.externalId'])) { + if (isset($response['errors']['customer.externalId'])) { $order['customer'] = $this->createCustomer($data); $response = $retailcrmApiClient->ordersEdit($order); } @@ -97,9 +97,9 @@ class ModelExtensionRetailcrmOrder extends Model { $shippingModule = $shippingCode[0]; if (isset($this->settings[$this->moduleTitle . '_delivery'][$order_data['shipping_code']])) { - $delivery_code = $this->settings[$this->moduleTitle . '_delivery'][$order_data['shipping_code']]; + $delivery_code = $this->settings[$this->moduleTitle . '_delivery'][$order_data['shipping_code']]; } elseif (isset($this->settings[$this->moduleTitle . '_delivery'][$shippingModule])) { - $delivery_code = $this->settings[$this->moduleTitle . '_delivery'][$shippingModule]; + $delivery_code = $this->settings[$this->moduleTitle . '_delivery'][$shippingModule]; } } @@ -414,7 +414,7 @@ class ModelExtensionRetailcrmOrder extends Model { /** * @param array $data * - * @return array + * @return array $customer */ private function createCustomer($data) {