Skip to content

Commit c6352de

Browse files
authored
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
2 parents 638b94e + 0c7c310 commit c6352de

File tree

4 files changed

+63
-33
lines changed

4 files changed

+63
-33
lines changed

classes/SpecificPrice.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@ protected static function _getScoreQuery($id_product, $id_shop, $id_currency, $i
180180
$select = '(';
181181

182182
$priority = SpecificPrice::getPriority($id_product);
183+
if (!Group::isFeatureActive()) {
184+
if (($key = array_search('id_group', $priority)) !== false) {
185+
unset($priority[$key]);
186+
}
187+
}
188+
183189
foreach (array_reverse($priority) as $k => $field) {
184190
if (!empty($field)) {
185191
$select .= ' IF (`'.bqSQL($field).'` = '.(int)$$field.', '.pow(2, $k + 1).', 0) + ';
@@ -358,8 +364,8 @@ public static function getSpecificPrice($id_product, $id_shop, $id_currency, $id
358364
WHERE
359365
`id_shop` '.self::formatIntInQuery(0, $id_shop).' AND
360366
`id_currency` '.self::formatIntInQuery(0, $id_currency).' AND
361-
`id_country` '.self::formatIntInQuery(0, $id_country).' AND
362-
`id_group` '.self::formatIntInQuery(0, $id_group).' '.$query_extra.'
367+
`id_country` '.self::formatIntInQuery(0, $id_country).
368+
(Group::isFeatureActive() ? ' AND `id_group` '.self::formatIntInQuery(0, $id_group) : '').' '.$query_extra.'
363369
AND IF(`from_quantity` > 1, `from_quantity`, 0) <= ';
364370

365371
$query .= (Configuration::get('PS_QTY_DISCOUNT_ON_COMBINATION') || !$id_cart || !$real_quantity) ? (int)$quantity : max(1, (int)$real_quantity);

controllers/admin/AdminGroupsController.php

+25-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public function initToolbar()
126126

127127
public function initPageHeaderToolbar()
128128
{
129-
if (empty($this->display)) {
129+
if (empty($this->display) && Group::isFeatureActive()) {
130130
$this->page_header_toolbar_btn['new_group'] = array(
131131
'href' => self::$currentIndex.'&addgroup&token='.$this->token,
132132
'desc' => $this->l('Add new group', null, null, false),
@@ -148,8 +148,32 @@ public function initProcess()
148148
parent::initProcess();
149149
}
150150

151+
public function initContent()
152+
{
153+
if (!Group::isFeatureActive()) {
154+
parent::initContent();
155+
156+
$content = $this->displayWarning(sprintf(
157+
$this->l('The feature Customer Groups has been disabled. You can enable it from %s page.'),
158+
'<a href="'.$this->context->link->getAdminLink('AdminPerformance').'#fieldset_2_2" target="_blank">'.$this->l('Advanced Parameters > Performance').'</a>'
159+
));
160+
161+
$this->context->smarty->assign(array(
162+
'content' => $content,
163+
));
164+
165+
return;
166+
}
167+
168+
parent::initContent();
169+
}
170+
151171
public function postProcess()
152172
{
173+
if (!Group::isFeatureActive()) {
174+
return;
175+
}
176+
153177
if (isset($_POST['submitResetcustomer_group'])) {
154178
$this->processResetFilters('customer_group');
155179
}

controllers/admin/AdminPerformanceController.php

+21-21
Original file line numberDiff line numberDiff line change
@@ -212,27 +212,27 @@ public function initFieldsetFeaturesDetachables()
212212
'type' => 'hidden',
213213
'name' => 'features_detachables_up'
214214
),
215-
array(
216-
'type' => 'switch',
217-
'label' => $this->l('Combinations'),
218-
'name' => 'combination',
219-
'is_bool' => true,
220-
'disabled' => Combination::isCurrentlyUsed(),
221-
'values' => array(
222-
array(
223-
'id' => 'combination_1',
224-
'value' => 1,
225-
'label' => $this->l('Yes'),
226-
),
227-
array(
228-
'id' => 'combination_0',
229-
'value' => 0,
230-
'label' => $this->l('No')
231-
)
232-
),
233-
'hint' => $this->l('Choose "No" to disable Product Combinations.'),
234-
'desc' => Combination::isCurrentlyUsed() ? $this->l('You cannot set this parameter to No when combinations are already used by some of your products') : null
235-
),
215+
// array(
216+
// 'type' => 'switch',
217+
// 'label' => $this->l('Combinations'),
218+
// 'name' => 'combination',
219+
// 'is_bool' => true,
220+
// 'disabled' => Combination::isCurrentlyUsed(),
221+
// 'values' => array(
222+
// array(
223+
// 'id' => 'combination_1',
224+
// 'value' => 1,
225+
// 'label' => $this->l('Yes'),
226+
// ),
227+
// array(
228+
// 'id' => 'combination_0',
229+
// 'value' => 0,
230+
// 'label' => $this->l('No')
231+
// )
232+
// ),
233+
// 'hint' => $this->l('Choose "No" to disable Product Combinations.'),
234+
// 'desc' => Combination::isCurrentlyUsed() ? $this->l('You cannot set this parameter to No when combinations are already used by some of your products') : null
235+
// ),
236236
array(
237237
'type' => 'switch',
238238
'label' => $this->l('Features'),

modules/hotelreservationsystem/classes/HotelCartBookingData.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -1282,19 +1282,19 @@ public function getProductFeaturePricePlanByDateByPriority(
12821282
foreach ($featurePricePriority as $priority) {
12831283
if ($priority == 'specific_date') {
12841284
if ($featurePrice = Db::getInstance()->getRow(
1285-
'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` fp
1286-
INNER JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` fpg
1287-
ON (fp.`id_feature_price` = fpg.`id_feature_price` AND fpg.`id_group` = '.(int) $id_group.')
1285+
'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` fp'.
1286+
(Group::isFeatureActive() ? ' INNER JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` fpg
1287+
ON (fp.`id_feature_price` = fpg.`id_feature_price` AND fpg.`id_group` = '.(int) $id_group.')' : '').'
12881288
WHERE fp.`id_cart` = 0 AND fp.`id_product`='.(int) $id_product.' AND fp.`active`=1
12891289
AND fp.`date_selection_type` = '.(int) HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC.' AND fp.`date_from` = \''.pSQL($date).'\''
12901290
)) {
12911291
return $featurePrice;
12921292
}
12931293
} elseif ($priority == 'special_day') {
12941294
if ($featurePrice = Db::getInstance()->executeS(
1295-
'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` fp
1296-
INNER JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` fpg
1297-
ON (fp.`id_feature_price` = fpg.`id_feature_price` AND fpg.`id_group` = '.(int) $id_group.')
1295+
'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` fp'.
1296+
(Group::isFeatureActive() ? ' INNER JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` fpg
1297+
ON (fp.`id_feature_price` = fpg.`id_feature_price` AND fpg.`id_group` = '.(int) $id_group.')' : '').'
12981298
WHERE fp.`id_cart` = 0 AND fp.`id_product`='.(int) $id_product.'
12991299
AND fp.`is_special_days_exists`=1 AND fp.`active`=1 AND fp.`date_from` <= \''.pSQL($date).'\'
13001300
AND fp.`date_to` >= \''.pSQL($date).'\''
@@ -1308,9 +1308,9 @@ public function getProductFeaturePricePlanByDateByPriority(
13081308
}
13091309
} elseif ($priority == 'date_range') {
13101310
if ($featurePrice = Db::getInstance()->getRow(
1311-
'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` fp
1312-
INNER JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` fpg
1313-
ON (fp.`id_feature_price` = fpg.`id_feature_price` AND fpg.`id_group` = '.(int) $id_group.')
1311+
'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` fp'.
1312+
(Group::isFeatureActive() ? ' INNER JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` fpg
1313+
ON (fp.`id_feature_price` = fpg.`id_feature_price` AND fpg.`id_group` = '.(int) $id_group.')' : '').'
13141314
WHERE fp.`id_cart` = 0 AND fp.`id_product`='.(int) $id_product.' AND fp.`date_selection_type` = '.(int) HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE.'
13151315
AND `is_special_days_exists`=0 AND `active`=1
13161316
AND fp.`date_from` <= \''.pSQL($date).'\' AND fp.`date_to` >= \''.pSQL($date).'\''

0 commit comments

Comments
 (0)