Handle the promotional price

This commit is contained in:
Yura 2020-12-04 14:33:29 +03:00 committed by GitHub
parent cd7f63562d
commit bb23c4cc40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 8 deletions

View File

@ -171,13 +171,13 @@ class ModelExtensionRetailcrmPrices extends Model
) { ) {
$productPrice[$special['customer_group_id']]['price'] = $special['price']; $productPrice[$special['customer_group_id']]['price'] = $special['price'];
$productPrice[$special['customer_group_id']]['remove'] = false; $productPrice[$special['customer_group_id']]['remove'] = false;
$priority = $special['priority'];
$groupId = $special['customer_group_id']; $groupId = $special['customer_group_id'];
$priority = $special['priority'];
} }
} else { } else {
$productPrice[$special['customer_group_id']]['price'] = $special['price']; $productPrice[$special['customer_group_id']]['price'] = $special['price'];
$groupId = $special['customer_group_id'];
$productPrice[$special['customer_group_id']]['remove'] = false; $productPrice[$special['customer_group_id']]['remove'] = false;
$groupId = $special['customer_group_id'];
} }
} }
} }

View File

@ -234,19 +234,29 @@ class RetailcrmOrderConverter {
'quantity' => $product['quantity'] 'quantity' => $product['quantity']
); );
$date = date('Y-m-d');
$always = '0000-00-00';
$specials = $this->productsRepository->getProductSpecials($product['product_id']); $specials = $this->productsRepository->getProductSpecials($product['product_id']);
if (!empty($specials)) { if (!empty($specials)) {
$customer = $this->customerRepository->getCustomer($this->order_data['customer_id']); $customer = $this->customerRepository->getCustomer($this->order_data['customer_id']);
foreach ($specials as $special) { foreach ($specials as $special) {
if (empty($customer['customer_group_id'])) { if (($special['date_start'] == $always && $special['date_end'] == $always)
continue; || ($special['date_start'] <= $date && $special['date_end'] >= $date)
} ) {
if ((isset($priority) && $priority > $special['priority'])
|| !isset($priority)) {
if (empty($customer['customer_group_id'])) {
continue;
}
$specialSetting = $this->settingsManager->getSetting('special_' . $customer['customer_group_id']); $specialSetting = $this->settingsManager->getSetting('special_' . $customer['customer_group_id']);
if ($special['customer_group_id'] == $customer['customer_group_id'] && !empty($specialSetting)) { if ($special['customer_group_id'] == $customer['customer_group_id'] && !empty($specialSetting)) {
$item['priceType']['code'] = $specialSetting; $item['priceType']['code'] = $specialSetting;
$priority = $special['priority'];
}
}
} }
} }
} }