Удаление типа цены товара для неустановленных акционных цен

This commit is contained in:
Sergey 2019-05-17 17:05:57 +03:00
parent 17140b16c5
commit 2018a0f7dd
3 changed files with 15 additions and 6 deletions

View File

@ -1,3 +1,7 @@
## v.3.1.4
* Добавлено удаление типа цены для неустановленных акционных цен
## v.3.1.3
* Добавлена возможность передачи акционных цен для нескольких групп пользователей
* Добавлена передача нулевой цены для неустановленных акционных цен

View File

@ -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;
}
}

View File

@ -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()