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..6a91725 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]['remove']); + $this->assertFalse($price['prices'][1]['remove']); + $this->assertNotFalse($price['prices'][2]['remove']); } private function getSites()