Merge pull request #152 from sergeygw1990/master

Удаление типа цены товара для неустановленных акционных цен
This commit is contained in:
Alex Lushpai 2019-05-24 11:39:45 +03:00 committed by GitHub
commit a69c4be480
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 7 deletions

View File

@ -1,3 +1,6 @@
## v.3.3.3
* Добавлено удаление типа цены товара для неустановленных акционных цен
## v.3.3.2 ## v.3.3.2
* Добавлен возврат остатка товара при отмене заказа * Добавлен возврат остатка товара при отмене заказа

View File

@ -1 +1 @@
3.3.2 3.3.3

View File

@ -129,10 +129,12 @@ class ModelExtensionRetailcrmPrices extends Model
$price = array(); $price = array();
foreach($productPrice as $k => $v) { foreach($productPrice as $k => $v) {
if (isset($this->settings[$this->moduleTitle . '_special_' . $k])) { if (isset($this->settings[$this->moduleTitle . '_special_' . $k])) {
$price[] = array( $price[] = array(
'code' => $this->settings[$this->moduleTitle . '_special_' . $k], 'code' => $this->settings[$this->moduleTitle . '_special_' . $k],
'price' => $v == 0 ? $v : $v + $optionsValues['price'] 'price' => !$v['remove'] ? $v['price'] + $optionsValues['price'] : 0,
'remove' => $v['remove']
); );
} }
} }
@ -168,13 +170,15 @@ class ModelExtensionRetailcrmPrices extends Model
if ((isset($priority) && $priority > $special['priority']) if ((isset($priority) && $priority > $special['priority'])
|| !isset($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']; $priority = $special['priority'];
$groupId = $special['customer_group_id']; $groupId = $special['customer_group_id'];
} }
} else { } else {
$productPrice[$special['customer_group_id']] = $special['price']; $productPrice[$special['customer_group_id']]['price'] = $special['price'];
$groupId = $special['customer_group_id']; $groupId = $special['customer_group_id'];
$productPrice[$special['customer_group_id']]['remove'] = false;
} }
} }
} }
@ -183,7 +187,7 @@ class ModelExtensionRetailcrmPrices extends Model
foreach ($customerGroups as $customerGroup) { foreach ($customerGroups as $customerGroup) {
if (!isset($productPrice[$customerGroup['customer_group_id']])){ if (!isset($productPrice[$customerGroup['customer_group_id']])){
$productPrice[$customerGroup['customer_group_id']] = 0; $productPrice[$customerGroup['customer_group_id']]['remove'] = true;
} }
} }
@ -201,7 +205,7 @@ class ModelExtensionRetailcrmPrices extends Model
$productPrice = array(); $productPrice = array();
foreach ($customerGroups as $customerGroup) { foreach ($customerGroups as $customerGroup) {
$productPrice[$customerGroup['customer_group_id']] = 0; $productPrice[$customerGroup['customer_group_id']]['remove'] = true;
} }
return $productPrice; return $productPrice;

View File

@ -62,7 +62,9 @@ class ModelRetailcrmPricesAdminTest extends OpenCartTest
$this->assertEquals('special1', $price['prices'][0]['code']); $this->assertEquals('special1', $price['prices'][0]['code']);
$this->assertEquals('special2', $price['prices'][1]['code']); $this->assertEquals('special2', $price['prices'][1]['code']);
$this->assertEquals('special3', $price['prices'][2]['code']); $this->assertEquals('special3', $price['prices'][2]['code']);
$this->assertEquals(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 sites(){ private function sites(){