From 9fc8b5131b042b5fb7cbfd22ce66d3d781d3e2da Mon Sep 17 00:00:00 2001 From: Gena Date: Thu, 26 Apr 2018 22:22:17 +0300 Subject: [PATCH 1/2] =?UTF-8?q?=D0=94=D0=BB=D1=8F=20=D0=B4=D0=B0=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D0=B5=D0=B9=D1=88=D0=B5=D0=B3=D0=BE=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B7=D0=B2=D0=B8=D1=82=D0=B8=D1=8F=20=D0=BA=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D1=81=D0=B0=20=D1=84=D0=B8=D0=BA=D1=81!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Правильная кастомизация данных, согласно типам в свойстве класса, во избежании ошибок с подсчетом в следующих версиях! --- lib/classes/shopOrder.class.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/classes/shopOrder.class.php b/lib/classes/shopOrder.class.php index b87603111..61c2a9e39 100644 --- a/lib/classes/shopOrder.class.php +++ b/lib/classes/shopOrder.class.php @@ -655,11 +655,22 @@ protected function getRate($currency = null) protected function getSubtotal() { $subtotal = 0.0; - foreach ($this->items as $i) { - $subtotal += floatval($i['price']) * intval($i['quantity']); + if(array_key_exists('type', $i)) { + switch ($i['type']) { + case 'product': + $this->formatValues($i, self::$product_fields); + break; + case 'service': + $this->formatValues($i, self::$service_fields); + break; + } + } else { + $i['price'] = $this->formatValue($i['price'], 'float'); + $i['quantity'] = $this->formatValue($i['price'], 'int'); + } + $subtotal += $i['price']*$i['quantity']; } - return $subtotal; } From 818764884ca183a81a5191849f13348e897f3c06 Mon Sep 17 00:00:00 2001 From: Gena Date: Thu, 26 Apr 2018 22:51:39 +0300 Subject: [PATCH 2/2] Update shopOrder.class.php --- lib/classes/shopOrder.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/classes/shopOrder.class.php b/lib/classes/shopOrder.class.php index 61c2a9e39..6575f33e5 100644 --- a/lib/classes/shopOrder.class.php +++ b/lib/classes/shopOrder.class.php @@ -667,7 +667,7 @@ protected function getSubtotal() } } else { $i['price'] = $this->formatValue($i['price'], 'float'); - $i['quantity'] = $this->formatValue($i['price'], 'int'); + $i['quantity'] = $this->formatValue($i['quantity'], 'int'); } $subtotal += $i['price']*$i['quantity']; }