Optimized code, changed the depricate function HotelRoomTypeFeaturePricing::deleteByIdCart() calls with HotelRoomTypeFeaturePricing::deleteFeaturePrices()

This commit is contained in:
vishalsingh.qlo325
2025-04-16 13:00:25 +05:30
parent 4e3523f1b4
commit 232e16af2d
6 changed files with 19 additions and 18 deletions

View File

@@ -1384,7 +1384,7 @@ abstract class PaymentModuleCore extends Module
} // End foreach $order_detail_list
// delete cart feature prices after booking creation success
HotelRoomTypeFeaturePricing::deleteByIdCart($id_cart);
HotelRoomTypeFeaturePricing::deleteFeaturePrices($id_cart);
if (count($cart_rules)) {
foreach ($cart_rules as $idCartRule => $cartRule) {

View File

@@ -1710,7 +1710,7 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We
'id_cart' => (int) $this->context->cart->id,
'id_guest' => (int) $this->context->cart->id_guest,
'date_from' => date('Y-m-d', strtotime($dateFrom)),
'date_to' => date('Y-m-d', strtotime($dateTo)),
'date_to' => date('Y-m-d', strtotime($dateTo) - _TIME_1_DAY_),
'id_room' => $objCartBookingData->id_room,
'price' => $room['unit_price_without_tax']
)
@@ -2331,7 +2331,7 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We
}
$this->deleteWsFeaturePrices();
HotelRoomTypeFeaturePricing::deleteByIdCart($this->context->cart->id);
HotelRoomTypeFeaturePricing::deleteFeaturePrices($this->context->cart->id);
}
/**
@@ -2878,8 +2878,8 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We
$objRoomTypeFeaturePricing->id_room = (int) $params['id_room'];
$objRoomTypeFeaturePricing->feature_price_name = $feature_price_name;
$objRoomTypeFeaturePricing->date_selection_type = HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE;
$objRoomTypeFeaturePricing->date_from = date('Y-m-d', strtotime($params['date_from']));
$objRoomTypeFeaturePricing->date_to = date('Y-m-d', (strtotime($params['date_to']) - _TIME_1_DAY_));
$objRoomTypeFeaturePricing->date_from = $params['date_from'];
$objRoomTypeFeaturePricing->date_to = $params['date_to'];
$objRoomTypeFeaturePricing->is_special_days_exists = 0;
$objRoomTypeFeaturePricing->special_days = json_encode(false);
$objRoomTypeFeaturePricing->impact_way = HotelRoomTypeFeaturePricing::IMPACT_WAY_FIX_PRICE;
@@ -2970,7 +2970,7 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We
'id_cart' => (int) $objCart->id,
'id_guest' => (int) $objCart->id_guest,
'date_from' => date('Y-m-d', strtotime($objHotelBookingDetail->date_from)),
'date_to' => date('Y-m-d', strtotime($objHotelBookingDetail->date_to)),
'date_to' => date('Y-m-d', strtotime($objHotelBookingDetail->date_to) - _TIME_1_DAY_),
'id_room' => $objHotelBookingDetail->id_room,
'price' => $room['unit_price_without_tax']
)
@@ -3006,7 +3006,7 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We
$objOrder->total_products_wt += $objHotelBookingDetail->total_price_tax_incl;
$objOrder->update();
HotelRoomTypeFeaturePricing::deleteByIdCart($objCart->id);
HotelRoomTypeFeaturePricing::deleteFeaturePrices($objCart->id);
$this->deleteWsFeaturePrices();
}
}

View File

@@ -960,7 +960,7 @@ class AdminCartsControllerCore extends AdminController
}
if ($this->tabAccess['edit'] === '1') {
HotelRoomTypeFeaturePricing::deleteByIdCart($id_cart, $id_product, $id_room, $date_from, $date_to);
HotelRoomTypeFeaturePricing::deleteFeaturePrices($id_cart, $id_product, $id_room, $date_from, $date_to);
$feature_price_name = array();
foreach (Language::getIDs(true) as $id_lang) {
$feature_price_name[$id_lang] = 'Auto-generated';

View File

@@ -4681,7 +4681,7 @@ class AdminOrdersControllerCore extends AdminController
}
// delete cart feature prices after room addition success
HotelRoomTypeFeaturePricing::deleteByIdCart($this->context->cart->id);
HotelRoomTypeFeaturePricing::deleteFeaturePrices($this->context->cart->id);
die(json_encode(array(
'result' => true,
@@ -4842,7 +4842,7 @@ class AdminOrdersControllerCore extends AdminController
}
// delete cart feature prices after booking update success
HotelRoomTypeFeaturePricing::deleteByIdCart($cart->id);
HotelRoomTypeFeaturePricing::deleteFeaturePrices($cart->id);
// Calculate differences of price (Before / After)
$diff_price_tax_incl = $totalRoomPriceAfterTI - $totalRoomPriceBeforeTI;

View File

@@ -2136,7 +2136,7 @@ class HotelBookingDetail extends ObjectModel
}
// delete cart feature prices after room addition success
HotelRoomTypeFeaturePricing::deleteByIdCart($this->context->cart->id);
HotelRoomTypeFeaturePricing::deleteFeaturePrices($this->context->cart->id);
// ===============================================================
// END: Add Process of the old booking

View File

@@ -363,7 +363,8 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
$params['roomTypeId'] = $id_product;
$params['featurePriceName'] = 'Webservice Feature Price';
$params['dateFrom'] = $dateFrom;
$params['dateTo'] = $dateTo;
$featurePriceDateTo = date('Y-m-d', (strtotime($dateTo) - _TIME_1_DAY_));
$params['dateTo'] = $featurePriceDateTo;
$params['priceImpactWay'] = $priceImpactWay;
$params['isSpecialDaysExists'] = 0;
$params['jsonSpecialDays'] = null;
@@ -376,7 +377,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
$featurePriceExists = $this->checkRoomTypeFeaturePriceExistance(
$id_product,
$dateFrom,
$dateTo,
$featurePriceDateTo,
'specific_date'
);
if ($featurePriceExists) {
@@ -393,12 +394,12 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
$featurePriceExists = $this->checkRoomTypeFeaturePriceExistance(
$id_product,
$dateFrom,
$dateTo,
$featurePriceDateTo,
'date_range'
);
if ($featurePriceExists) {
if ($featurePriceExists['date_from'] == $dateFrom
&& $featurePriceExists['date_to'] == $dateTo
&& $featurePriceExists['date_to'] == $featurePriceDateTo
) {
if (!$this->saveFeaturePricePlan(
$featurePriceExists['id'],
@@ -409,8 +410,8 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
}
} else {
for($date = $dateFrom; $date < $dateTo; $date = date('Y-m-d', strtotime('+1 day', strtotime($date)))) {
$currentDate = date('Y-m-d', $date);
$nextDayDate = date('Y-m-d', strtotime('+1 day', strtotime($currentDate)));
// Creating feature prices day wise, for single days.
$nextDayDate = $currentDate = date('Y-m-d', $date);
$params['dateFrom'] = $currentDate;
$params['dateTo'] = $nextDayDate;
$params['dateSelectionType'] = self::DATE_SELECTION_TYPE_SPECIFIC;
@@ -611,7 +612,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
$roomTypeFeaturePricing->date_selection_type = $params['dateSelectionType'];
$roomTypeFeaturePricing->date_from = $params['dateFrom'];
$roomTypeFeaturePricing->date_to = date('Y-m-d', (strtotime($params['dateTo']) - _TIME_1_DAY_));
$roomTypeFeaturePricing->date_to = $params['dateTo'];
$roomTypeFeaturePricing->impact_way = $params['priceImpactWay'];
$roomTypeFeaturePricing->is_special_days_exists = $params['isSpecialDaysExists'];
$roomTypeFeaturePricing->special_days = $params['jsonSpecialDays'];