From 769f35f37936fb8bacd01ec826bc831d2c324e23 Mon Sep 17 00:00:00 2001 From: DanielWeiser <46303277+DanielWeiser@users.noreply.github.com> Date: Thu, 24 Sep 2020 10:52:14 +0300 Subject: [PATCH] fix compatibility with php 5.4 (#197) --- .../admin/model/extension/retailcrm/icml.php | 2 +- .../lib/service/RetailcrmOrderConverter.php | 21 ++++++++++++------- .../system/library/retailcrm/retailcrm.php | 6 +++--- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/upload/admin/model/extension/retailcrm/icml.php b/src/upload/admin/model/extension/retailcrm/icml.php index 4c5087a..05f820a 100644 --- a/src/upload/admin/model/extension/retailcrm/icml.php +++ b/src/upload/admin/model/extension/retailcrm/icml.php @@ -234,7 +234,7 @@ class ModelExtensionRetailcrmIcml extends Model * Dimensions */ if ((!empty($product['length']) && $product['length'] > 0) && - (!empty($product['width'] && $product['width'] > 0)) + (!empty($product['width']) && $product['width'] > 0) && !empty($product['height'])) { $lenghtArray = $this->model_localisation_length_class->getLengthClass($product['length_class_id']); diff --git a/src/upload/system/library/retailcrm/lib/service/RetailcrmOrderConverter.php b/src/upload/system/library/retailcrm/lib/service/RetailcrmOrderConverter.php index 35e09d1..9c060a8 100644 --- a/src/upload/system/library/retailcrm/lib/service/RetailcrmOrderConverter.php +++ b/src/upload/system/library/retailcrm/lib/service/RetailcrmOrderConverter.php @@ -76,17 +76,20 @@ class RetailcrmOrderConverter { public function setDiscount() { $discount = 0; + $totalCoupon = $this->getTotal('coupon'); + $totalReward = $this->getTotal('reward'); + $totalVoucher = $this->getTotal('voucher'); - if (!empty($this->getTotal('coupon'))) { - $discount += abs($this->getTotal('coupon')); + if (!empty($totalCoupon)) { + $discount += abs($totalCoupon); } - if (!empty($this->getTotal('reward'))) { - $discount += abs($this->getTotal('reward')); + if (!empty($totalReward)) { + $discount += abs($totalReward); } - if (!empty($this->getTotal('voucher'))) { - $discount += abs($this->getTotal('voucher')); + if (!empty($totalVoucher)) { + $discount += abs($totalVoucher); } if ($discount > 0) { @@ -169,8 +172,10 @@ class RetailcrmOrderConverter { $this->data['delivery']['code'] = $delivery_code; } - if (!empty($this->getTotal('shipping'))) { - $this->data['delivery']['cost'] = $this->getTotal('shipping'); + $totalShipping = $this->getTotal('shipping'); + + if (!empty($totalShipping)) { + $this->data['delivery']['cost'] = $totalShipping; } return $this; diff --git a/src/upload/system/library/retailcrm/retailcrm.php b/src/upload/system/library/retailcrm/retailcrm.php index a4f828d..f9930e2 100644 --- a/src/upload/system/library/retailcrm/retailcrm.php +++ b/src/upload/system/library/retailcrm/retailcrm.php @@ -57,7 +57,7 @@ class Retailcrm { * @return mixed object | boolean */ public function getApiClient($apiUrl = null, $apiKey = null, $apiVersion = null) { - if (!$this->registry->has(\RetailcrmProxy::class)) { + if (!$this->registry->has('RetailcrmProxy')) { $setting = $this->model_setting_setting->getSetting($this->getModuleTitle()); if ($apiUrl === null && $apiKey === null) { @@ -72,12 +72,12 @@ class Retailcrm { } $this->registry->set( - \RetailcrmProxy::class, + 'RetailcrmProxy', new \RetailcrmProxy($apiUrl, $apiKey) ); } - return $this->registry->get(\RetailcrmProxy::class); + return $this->registry->get('RetailcrmProxy'); } /**