mirror of
https://github.com/retailcrm/opencart-module.git
synced 2024-11-25 06:36:06 +03:00
refactoring
This commit is contained in:
parent
53767392e9
commit
caf55f67ad
@ -48,16 +48,16 @@ class ModelExtensionRetailcrmOrder extends Model {
|
|||||||
if ($create) {
|
if ($create) {
|
||||||
$order = self::filterRecursive($order);
|
$order = self::filterRecursive($order);
|
||||||
$response = $retailcrmApiClient->ordersCreate($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);
|
$order['customer'] = $this->createCustomer($data);
|
||||||
$response = $retailcrmApiClient->ordersEdit($order);
|
$response = $retailcrmApiClient->ordersCreate($order);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$order_payment = reset($order['payments']);
|
$order_payment = reset($order['payments']);
|
||||||
unset($order['payments']);
|
unset($order['payments']);
|
||||||
$order = self::filterRecursive($order);
|
$order = self::filterRecursive($order);
|
||||||
$response = $retailcrmApiClient->ordersEdit($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);
|
$order['customer'] = $this->createCustomer($data);
|
||||||
$response = $retailcrmApiClient->ordersEdit($order);
|
$response = $retailcrmApiClient->ordersEdit($order);
|
||||||
}
|
}
|
||||||
@ -414,7 +414,7 @@ class ModelExtensionRetailcrmOrder extends Model {
|
|||||||
/**
|
/**
|
||||||
* @param array $data
|
* @param array $data
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array $customer
|
||||||
*/
|
*/
|
||||||
private function createCustomer($data)
|
private function createCustomer($data)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user