Merge pull request #835 from abhishek-webkul/gli-1066

Updated: Make Customer Groups inaccessible if option Customer Groups is disabled on Advanced Parameters > Performance page
This commit is contained in:
Rohit Jain
2024-03-15 16:55:30 +05:30
committed by GitHub
4 changed files with 63 additions and 33 deletions

View File

@@ -180,6 +180,12 @@ class SpecificPriceCore extends ObjectModel
$select = '(';
$priority = SpecificPrice::getPriority($id_product);
if (!Group::isFeatureActive()) {
if (($key = array_search('id_group', $priority)) !== false) {
unset($priority[$key]);
}
}
foreach (array_reverse($priority) as $k => $field) {
if (!empty($field)) {
$select .= ' IF (`'.bqSQL($field).'` = '.(int)$$field.', '.pow(2, $k + 1).', 0) + ';
@@ -358,8 +364,8 @@ class SpecificPriceCore extends ObjectModel
WHERE
`id_shop` '.self::formatIntInQuery(0, $id_shop).' AND
`id_currency` '.self::formatIntInQuery(0, $id_currency).' AND
`id_country` '.self::formatIntInQuery(0, $id_country).' AND
`id_group` '.self::formatIntInQuery(0, $id_group).' '.$query_extra.'
`id_country` '.self::formatIntInQuery(0, $id_country).
(Group::isFeatureActive() ? ' AND `id_group` '.self::formatIntInQuery(0, $id_group) : '').' '.$query_extra.'
AND IF(`from_quantity` > 1, `from_quantity`, 0) <= ';
$query .= (Configuration::get('PS_QTY_DISCOUNT_ON_COMBINATION') || !$id_cart || !$real_quantity) ? (int)$quantity : max(1, (int)$real_quantity);

View File

@@ -126,7 +126,7 @@ class AdminGroupsControllerCore extends AdminController
public function initPageHeaderToolbar()
{
if (empty($this->display)) {
if (empty($this->display) && Group::isFeatureActive()) {
$this->page_header_toolbar_btn['new_group'] = array(
'href' => self::$currentIndex.'&addgroup&token='.$this->token,
'desc' => $this->l('Add new group', null, null, false),
@@ -148,8 +148,32 @@ class AdminGroupsControllerCore extends AdminController
parent::initProcess();
}
public function initContent()
{
if (!Group::isFeatureActive()) {
parent::initContent();
$content = $this->displayWarning(sprintf(
$this->l('The feature Customer Groups has been disabled. You can enable it from %s page.'),
'<a href="'.$this->context->link->getAdminLink('AdminPerformance').'#fieldset_2_2" target="_blank">'.$this->l('Advanced Parameters > Performance').'</a>'
));
$this->context->smarty->assign(array(
'content' => $content,
));
return;
}
parent::initContent();
}
public function postProcess()
{
if (!Group::isFeatureActive()) {
return;
}
if (isset($_POST['submitResetcustomer_group'])) {
$this->processResetFilters('customer_group');
}

View File

@@ -212,27 +212,27 @@ class AdminPerformanceControllerCore extends AdminController
'type' => 'hidden',
'name' => 'features_detachables_up'
),
array(
'type' => 'switch',
'label' => $this->l('Combinations'),
'name' => 'combination',
'is_bool' => true,
'disabled' => Combination::isCurrentlyUsed(),
'values' => array(
array(
'id' => 'combination_1',
'value' => 1,
'label' => $this->l('Yes'),
),
array(
'id' => 'combination_0',
'value' => 0,
'label' => $this->l('No')
)
),
'hint' => $this->l('Choose "No" to disable Product Combinations.'),
'desc' => Combination::isCurrentlyUsed() ? $this->l('You cannot set this parameter to No when combinations are already used by some of your products') : null
),
// array(
// 'type' => 'switch',
// 'label' => $this->l('Combinations'),
// 'name' => 'combination',
// 'is_bool' => true,
// 'disabled' => Combination::isCurrentlyUsed(),
// 'values' => array(
// array(
// 'id' => 'combination_1',
// 'value' => 1,
// 'label' => $this->l('Yes'),
// ),
// array(
// 'id' => 'combination_0',
// 'value' => 0,
// 'label' => $this->l('No')
// )
// ),
// 'hint' => $this->l('Choose "No" to disable Product Combinations.'),
// 'desc' => Combination::isCurrentlyUsed() ? $this->l('You cannot set this parameter to No when combinations are already used by some of your products') : null
// ),
array(
'type' => 'switch',
'label' => $this->l('Features'),

View File

@@ -1282,9 +1282,9 @@ class HotelCartBookingData extends ObjectModel
foreach ($featurePricePriority as $priority) {
if ($priority == 'specific_date') {
if ($featurePrice = Db::getInstance()->getRow(
'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` fp
INNER JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` fpg
ON (fp.`id_feature_price` = fpg.`id_feature_price` AND fpg.`id_group` = '.(int) $id_group.')
'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` fp'.
(Group::isFeatureActive() ? ' INNER JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` fpg
ON (fp.`id_feature_price` = fpg.`id_feature_price` AND fpg.`id_group` = '.(int) $id_group.')' : '').'
WHERE fp.`id_cart` = 0 AND fp.`id_product`='.(int) $id_product.' AND fp.`active`=1
AND fp.`date_selection_type` = '.(int) HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC.' AND fp.`date_from` = \''.pSQL($date).'\''
)) {
@@ -1292,9 +1292,9 @@ class HotelCartBookingData extends ObjectModel
}
} elseif ($priority == 'special_day') {
if ($featurePrice = Db::getInstance()->executeS(
'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` fp
INNER JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` fpg
ON (fp.`id_feature_price` = fpg.`id_feature_price` AND fpg.`id_group` = '.(int) $id_group.')
'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` fp'.
(Group::isFeatureActive() ? ' INNER JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` fpg
ON (fp.`id_feature_price` = fpg.`id_feature_price` AND fpg.`id_group` = '.(int) $id_group.')' : '').'
WHERE fp.`id_cart` = 0 AND fp.`id_product`='.(int) $id_product.'
AND fp.`is_special_days_exists`=1 AND fp.`active`=1 AND fp.`date_from` <= \''.pSQL($date).'\'
AND fp.`date_to` >= \''.pSQL($date).'\''
@@ -1308,9 +1308,9 @@ class HotelCartBookingData extends ObjectModel
}
} elseif ($priority == 'date_range') {
if ($featurePrice = Db::getInstance()->getRow(
'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` fp
INNER JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` fpg
ON (fp.`id_feature_price` = fpg.`id_feature_price` AND fpg.`id_group` = '.(int) $id_group.')
'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` fp'.
(Group::isFeatureActive() ? ' INNER JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` fpg
ON (fp.`id_feature_price` = fpg.`id_feature_price` AND fpg.`id_group` = '.(int) $id_group.')' : '').'
WHERE fp.`id_cart` = 0 AND fp.`id_product`='.(int) $id_product.' AND fp.`date_selection_type` = '.(int) HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE.'
AND `is_special_days_exists`=0 AND `active`=1
AND fp.`date_from` <= \''.pSQL($date).'\' AND fp.`date_to` >= \''.pSQL($date).'\''