Merge pull request #121 from iyzoer/v2.2

Fixes #21. Исправлена склейка типов доставки
This commit is contained in:
Alex Lushpai 2018-12-05 11:20:32 +03:00 committed by GitHub
commit d2d5bef98d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,11 +11,13 @@ class ControllerApiRetailcrm extends Controller
} else { } else {
$this->load->model('localisation/country'); $this->load->model('localisation/country');
$this->load->model('setting/setting'); $this->load->model('setting/setting');
$countries = $this->model_setting_setting->getSetting('retailcrm')['retailcrm_country']; $setting = $this->model_setting_setting->getSetting('retailcrm');
$response = array(); $response = array();
foreach ($countries as $country) { if (isset($setting['retailcrm_country']) && $setting['retailcrm_country']) {
$response = array_merge($response, $this->getDeliveryTypesByZones($country)); foreach ($setting['retailcrm_country'] as $country) {
$response = $this->mergeDeliveryTypes($country, $response);
}
} }
} }
@ -121,6 +123,18 @@ class ControllerApiRetailcrm extends Controller
return $deliveryTypes; return $deliveryTypes;
} }
private function mergeDeliveryTypes($country, $result) {
$delivery_types = $this->getDeliveryTypesByZones($country);
foreach ($delivery_types as $shipping_module => $shipping_type) {
if (isset($result[$shipping_module])) {
$result[$shipping_module] = array_merge($result[$shipping_module], $shipping_type);
} else {
$result[$shipping_module] = $shipping_type;
}
}
return $result;
}
private function auth() private function auth()
{ {
if (version_compare(VERSION, '2.1.0', '>=')) { if (version_compare(VERSION, '2.1.0', '>=')) {