From 45fde808b7af5edc14b0b67147190ef2e7519242 Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Wed, 6 Sep 2017 13:08:39 +0300 Subject: [PATCH] fix for opencart version > 3.0 --- catalog/controller/api/retailcrm.php | 4 ++-- catalog/model/extension/retailcrm/order.php | 20 ------------------- .../library/retailcrm/OpencartApiClient.php | 17 +++++++++++++--- 3 files changed, 16 insertions(+), 25 deletions(-) diff --git a/catalog/controller/api/retailcrm.php b/catalog/controller/api/retailcrm.php index b1441ce..b77f04d 100644 --- a/catalog/controller/api/retailcrm.php +++ b/catalog/controller/api/retailcrm.php @@ -5,8 +5,8 @@ class ControllerApiRetailcrm extends Controller { $this->load->model('localisation/country'); $this->load->model('setting/setting'); - - $countries = $this->model_setting_setting->getSetting('retailcrm')['retailcrm_country']; + $moduleTitle = $this->getModuleTitle(); + $countries = $this->model_setting_setting->getSetting($moduleTitle)[$moduleTitle . '_country']; $deliveryTypes = array(); foreach ($countries as $country) { diff --git a/catalog/model/extension/retailcrm/order.php b/catalog/model/extension/retailcrm/order.php index f722458..e9fafaa 100644 --- a/catalog/model/extension/retailcrm/order.php +++ b/catalog/model/extension/retailcrm/order.php @@ -259,16 +259,6 @@ class ModelExtensionRetailcrmOrder extends Model { 'amount' => $amount ); - if (version_compare(VERSION, '3.0', '<')) { - if ($order['order_status_id'] == $settingPaid[$order['payment_code'] . '_order_status_id']) { - $payment['status'] = 'paid'; - } - } else { - if ($order['order_status_id'] == $settingPaid['payment_' . $order['payment_code'] . '_order_status_id']) { - $payment['status'] = 'paid'; - } - } - $payment['order'] = array( 'externalId' => $order_id ); @@ -296,16 +286,6 @@ class ModelExtensionRetailcrmOrder extends Model { 'amount' => $amount ); - if (version_compare(VERSION, '3.0', '<')) { - if ($order['order_status_id'] == $settingPaid[$order['payment_code'] . '_order_status_id']) { - $payment['status'] = 'paid'; - } - } else { - if ($order['order_status_id'] == $settingPaid['payment_' . $order['payment_code'] . '_order_status_id']) { - $payment['status'] = 'paid'; - } - } - $this->retailcrm->ordersPaymentEdit($payment); } diff --git a/system/library/retailcrm/OpencartApiClient.php b/system/library/retailcrm/OpencartApiClient.php index 47a8684..e9255e5 100644 --- a/system/library/retailcrm/OpencartApiClient.php +++ b/system/library/retailcrm/OpencartApiClient.php @@ -14,9 +14,9 @@ class OpencartApiClient { public function __construct(Registry &$registry) { $this->registry = $registry; - - $settings = $this->model_setting_setting->getSetting('retailcrm'); - $this->cookieFileName = $settings['retailcrm_apikey']; + $moduleTitle = $this->getModuleTitle(); + $settings = $this->model_setting_setting->getSetting($moduleTitle); + $this->cookieFileName = $settings[$moduleTitle . '_apikey']; $this->auth(); } @@ -331,4 +331,15 @@ class OpencartApiClient { return $api_token; } + + private function getModuleTitle() + { + if (version_compare(VERSION, '3.0', '<')){ + $title = 'retailcrm'; + } else { + $title = 'module_retailcrm'; + } + + return $title; + } }