From 2018a0f7dd277230ea8a21a755a0286ee951f8c4 Mon Sep 17 00:00:00 2001 From: Sergey Date: Fri, 17 May 2019 17:05:57 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D1=82=D0=B8=D0=BF=D0=B0=20=D1=86=D0=B5=D0=BD=D1=8B=20?= =?UTF-8?q?=D1=82=D0=BE=D0=B2=D0=B0=D1=80=D0=B0=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D0=BD=D0=B5=D1=83=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=BD=D1=8B=D1=85=20=D0=B0=D0=BA=D1=86=D0=B8=D0=BE?= =?UTF-8?q?=D0=BD=D0=BD=D1=8B=D1=85=20=D1=86=D0=B5=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 ++++ .../admin/model/extension/retailcrm/prices.php | 13 ++++++++----- tests/admin/ModelRetailcrmPricesAdminTest.php | 4 +++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fe0294..73b526f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v.3.1.4 +* Добавлено удаление типа цены для неустановленных акционных цен + + ## v.3.1.3 * Добавлена возможность передачи акционных цен для нескольких групп пользователей * Добавлена передача нулевой цены для неустановленных акционных цен diff --git a/src/upload/admin/model/extension/retailcrm/prices.php b/src/upload/admin/model/extension/retailcrm/prices.php index fe598c5..4cc72b0 100644 --- a/src/upload/admin/model/extension/retailcrm/prices.php +++ b/src/upload/admin/model/extension/retailcrm/prices.php @@ -120,7 +120,8 @@ class ModelExtensionRetailcrmPrices extends Model if (isset($settings[\Retailcrm\Retailcrm::MODULE . '_special_' . $k])) { $price[] = array( 'code' => $settings[\Retailcrm\Retailcrm::MODULE . '_special_' . $k], - 'price' => $v == 0 ? $v : $v + $optionsValues['price'] + 'price' => !$v['remove'] ? $v['price'] + $optionsValues['price'] : 0, + 'remove' => $v['remove'] ); } } @@ -146,7 +147,7 @@ class ModelExtensionRetailcrmPrices extends Model $productPrice = array(); foreach ($customerGroups as $customerGroup) { - $productPrice[$customerGroup['customer_group_id']] = 0; + $productPrice[$customerGroup['customer_group_id']]['remove'] = true; } return $productPrice; @@ -173,12 +174,14 @@ class ModelExtensionRetailcrmPrices extends Model if ((isset($priority) && $priority > $special['priority']) || !isset($priority) ) { - $productPrice[$special['customer_group_id']] = $special['price']; + $productPrice[$special['customer_group_id']]['price'] = $special['price']; + $productPrice[$special['customer_group_id']]['remove'] = false; $priority = $special['priority']; $groupId = $special['customer_group_id']; } } else { - $productPrice[$special['customer_group_id']] = $special['price']; + $productPrice[$special['customer_group_id']]['price'] = $special['price']; + $productPrice[$special['customer_group_id']]['remove'] = false; $groupId = $special['customer_group_id']; } } @@ -188,7 +191,7 @@ class ModelExtensionRetailcrmPrices extends Model foreach ($customerGroups as $customerGroup) { if (!isset($productPrice[$customerGroup['customer_group_id']])){ - $productPrice[$customerGroup['customer_group_id']] = 0; + $productPrice[$customerGroup['customer_group_id']]['remove'] = true; } } diff --git a/tests/admin/ModelRetailcrmPricesAdminTest.php b/tests/admin/ModelRetailcrmPricesAdminTest.php index 58790bc..8cd4bc8 100644 --- a/tests/admin/ModelRetailcrmPricesAdminTest.php +++ b/tests/admin/ModelRetailcrmPricesAdminTest.php @@ -58,7 +58,9 @@ class ModelRetailcrmPricesAdminTest extends OpenCartTest $this->assertSame('special1', $price['prices'][0]['code']); $this->assertSame('special2', $price['prices'][1]['code']); $this->assertSame('special3', $price['prices'][2]['code']); - $this->assertSame(0, $price['prices'][2]['price']); + $this->assertFalse($price['prices'][0]['price']); + $this->assertFalse($price['prices'][1]['price']); + $this->assertNotFalse($price['prices'][2]['price']); } private function getSites()