Fixed:Hide Roomtype restriction if roomtypes lessthan 2.

This commit is contained in:
azhar bhat
2026-10-01 11:55:19 +05:30
parent d8cf510fe5
commit 229b156e3b
3 changed files with 9 additions and 1 deletions

View File

@@ -97,7 +97,7 @@
<p class="radio">
<label for="apply_discount_to_selection">
<input type="radio" name="apply_discount_to" id="apply_discount_to_selection" value="selection"{if $currentTab->getFieldValue($currentObject, 'reduction_product')|intval == -2} checked="checked"{/if}{if $product_rule_groups|@count == 0}disabled="disabled"{/if} />
{l s='Selected Room Type(s)'}{if $product_rule_groups|@count == 0}&nbsp;<span id="apply_discount_to_selection_warning" class="text-muted clearfix"><i class="icon-warning-sign"></i> <a href="#" id="apply_discount_to_selection_shortcut">{l s='You must select some room types first'}</a></span>{/if}
{l s='Selected Room Type(s)'}{if $product_rule_groups|@count == 0}&nbsp;<span id="apply_discount_to_selection_warning" class="text-muted clearfix"><i class="icon-warning-sign"></i> {if $total_room_types > 1}<a href="#" id="apply_discount_to_selection_shortcut">{l s='You must select some room types first'}</a>{else}{l s='You must select some room types first'}{/if}</span>{/if}
</label>
</p>
</div>

View File

@@ -286,6 +286,8 @@
</div>
{/if}
{* keep the block visible when rules are already saved, so they are not hidden from the admin *}
{if $total_room_types > 1 || $product_rule_groups|@count}
<p class="checkbox">
<label>
<input type="checkbox" id="product_restriction" name="product_restriction" value="1" {if $product_rule_groups|@count}checked="checked"{/if} />
@@ -303,6 +305,7 @@
<i class="icon-plus-sign"></i> {l s='Room Type selection'}
</a>
</div>
{/if}
{if $shops.unselected|@count + $shops.selected|@count > 1}
<p class="checkbox">

View File

@@ -831,6 +831,10 @@ class AdminCartRulesControllerCore extends AdminController
$product_rule_groups = $this->getProductRuleGroupsDisplay($current_object);
// Room type restriction is useful only when there is more than one room type to choose from
$objHotelRoomType = new HotelRoomType();
$total_room_types = count($objHotelRoomType->getAllRoomTypes());
$attribute_groups = AttributeGroup::getAttributesGroups($this->context->language->id);
$currencies = Currency::getCurrencies(false, true, true);
$languages = Language::getLanguages();
@@ -901,6 +905,7 @@ class AdminCartRulesControllerCore extends AdminController
'cart_rules' => $cart_rules,
'product_rule_groups' => $product_rule_groups,
'product_rule_groups_counter' => count($product_rule_groups),
'total_room_types' => $total_room_types,
'attribute_groups' => $attribute_groups,
'currentIndex' => self::$currentIndex,
'currentToken' => $this->token,