Merge pull request #119 from iyzoer/master

v3.1.4
This commit is contained in:
Alex Lushpai 2018-11-01 15:34:50 +03:00 committed by GitHub
commit 5b700332b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 7 deletions

15
.env-dist Normal file
View File

@ -0,0 +1,15 @@
# OpenCart Database connection values
OC_DB_HOSTNAME=host
OC_DB_USERNAME=user
OC_DB_PASSWORD=pass
OC_DB_DATABASE=database
OC_DB_DRIVER=mysqli
# OpenCart Administration user
OC_USERNAME=admin
OC_PASSWORD=admin
OC_EMAIL=you@example.com
# Server Specification
SERVER_PORT=8000
SERVER_URL=http://localhost

View File

@ -1,3 +1,6 @@
## v.3.1.4
* Исправлена некорректная склейка типов доставки
## v.3.1.3
* Добавлена активация модуля в маркетплейсе retailCRM

View File

@ -1 +1 @@
3.1.3
3.1.4

View File

@ -1,6 +1,6 @@
<?php
class ControllerApiRetailcrm extends Controller
class ControllerApiRetailcrm extends Controller
{
public function getDeliveryTypes()
{
@ -14,11 +14,10 @@ class ControllerApiRetailcrm extends Controller
$this->load->library('retailcrm/retailcrm');
$moduleTitle = $this->retailcrm->getModuleTitle();
$setting = $this->model_setting_setting->getSetting($moduleTitle);
$response = array();
if (isset($setting[$moduleTitle . '_country']) && $setting[$moduleTitle . '_country']) {
foreach ($setting[$moduleTitle . '_country'] as $country) {
$response = array_merge($response, $this->getDeliveryTypesByZones($country));
$response = $this->mergeDeliveryTypes($country);
}
}
}
@ -60,7 +59,7 @@ class ControllerApiRetailcrm extends Controller
}
protected function getDeliveryTypesByZones($country_id)
{
{
$this->loadModels();
$this->load->model('localisation/zone');
$this->load->model('localisation/country');
@ -80,7 +79,7 @@ class ControllerApiRetailcrm extends Controller
'postcode' => '',
'city' => ''
);
foreach ($shippingModules as $shippingModule) {
$this->load->model('extension/shipping/' . $shippingModule['code']);
@ -98,7 +97,7 @@ class ControllerApiRetailcrm extends Controller
$this->config->set('free_total', 0);
}
}
if ($this->{'model_extension_shipping_' . $shippingModule['code']}->getQuote($address)) {
$quote_data[] = $this->{'model_extension_shipping_' . $shippingModule['code']}->getQuote($address);
} else {
@ -131,6 +130,21 @@ class ControllerApiRetailcrm extends Controller
return $deliveryTypes;
}
private function mergeDeliveryTypes($country) {
$result = array();
$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()
{
if (!isset($this->request->get['key'])