Merge pull request #956 from shreesh-webkul/revert-gli-1763
Revert "Improved: Orders are now split by hotel and booking duration"
This commit is contained in:
170
classes/Cart.php
170
classes/Cart.php
@@ -1797,18 +1797,13 @@ class CartCore extends ObjectModel
|
||||
(int)$product['id_product'],
|
||||
isset($product['id_hotel']) ? $product['id_hotel'] : 0,
|
||||
0,
|
||||
isset($product['date_from']) ? $product['date_from'] : 0,
|
||||
isset($product['date_to']) ? $product['date_to'] : 0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
$with_taxes,
|
||||
null
|
||||
);
|
||||
} else if ($roomTypesByIdProduct = $objCartBookingData->getCartInfoIdCartIdProduct(
|
||||
$this->id,
|
||||
$product['id_product'],
|
||||
isset($product['date_from']) ? $product['date_from'] : 0,
|
||||
isset($product['date_to']) ? $product['date_to'] : 0,
|
||||
)) {
|
||||
} else if ($roomTypesByIdProduct = $objCartBookingData->getCartInfoIdCartIdProduct($this->id, $product['id_product'])) {
|
||||
// by webkul to calculate rates of the product from hotelreservation syatem tables with feature prices....
|
||||
$totalPriceByProduct = 0;
|
||||
$priceDisplay = Group::getPriceDisplayMethod(Group::getCurrent()->id);
|
||||
@@ -2355,78 +2350,28 @@ class CartCore extends ObjectModel
|
||||
foreach ($packages as $id_package => $package) {
|
||||
foreach ($package['product_list'] as $product) {
|
||||
if ($product['booking_product']) {
|
||||
if ($roomsBookingDetails = $objHtlCartBookingData->getOnlyCartBookingData(
|
||||
$this->id,
|
||||
$this->id_guest,
|
||||
$product['id_product']
|
||||
)) {
|
||||
$productInfo = $objRoomType->getRoomTypeInfoByIdProduct($product['id_product']);
|
||||
$idHotel = $productInfo['id_hotel'] ? $productInfo['id_hotel'] : 0;
|
||||
$cartRoomInfo = array();
|
||||
foreach ($roomsBookingDetails as $roomBooking) {
|
||||
$dateJoinKey = $idHotel.'-'.strtotime($roomBooking['date_from']).strtotime($roomBooking['date_to']);
|
||||
$roomTotalPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice(
|
||||
$product['id_product'],
|
||||
$roomBooking['date_from'],
|
||||
$roomBooking['date_to'],
|
||||
0,
|
||||
Group::getCurrent()->id,
|
||||
$this->id,
|
||||
$this->id_guest,
|
||||
0,
|
||||
0
|
||||
);
|
||||
$newQty = HotelHelper::getNumberOfDays(
|
||||
$roomBooking['date_from'],
|
||||
$roomBooking['date_to']
|
||||
);
|
||||
if (isset($cartRoomInfo[$dateJoinKey])) {
|
||||
$cartRoomInfo[$dateJoinKey]['cart_quantity'] += $newQty;
|
||||
$cartRoomInfo[$dateJoinKey]['total_price_tax_incl'] += $roomTotalPrice['total_price_tax_incl'];
|
||||
$cartRoomInfo[$dateJoinKey]['total_price_tax_excl'] += $roomTotalPrice['total_price_tax_excl'];
|
||||
} else {
|
||||
$cartRoomInfo[$dateJoinKey] = array(
|
||||
'cart_quantity' => $newQty,
|
||||
'total_price_tax_incl' => $roomTotalPrice['total_price_tax_incl'],
|
||||
'total_price_tax_excl' => $roomTotalPrice['total_price_tax_excl'],
|
||||
'date_from' => $roomBooking['date_from'],
|
||||
'date_to' => $roomBooking['date_to'],
|
||||
);
|
||||
}
|
||||
}
|
||||
foreach ($cartRoomInfo as $dateJoinKey => $cartRoom) {
|
||||
if (!isset($orderPackage[$id_address][$dateJoinKey])) {
|
||||
$orderPackage[$id_address][$dateJoinKey]['product_list'] = array();
|
||||
$productInfo = $objRoomType->getRoomTypeInfoByIdProduct($product['id_product']);
|
||||
$idHotel = $productInfo['id_hotel'] ? $productInfo['id_hotel'] : 0;
|
||||
|
||||
$orderPackage[$id_address][$dateJoinKey]['id_hotel'] = $idHotel;
|
||||
if (!isset($orderPackage[$id_address][$dateJoinKey]['id_hotel'])) {
|
||||
$orderPackage[$id_address][$dateJoinKey]['id_hotel'] = $productInfo['id_hotel'];
|
||||
}
|
||||
if (!isset($orderPackage[$id_address][$dateJoinKey]['carrier_list'])) {
|
||||
$orderPackage[$id_address][$dateJoinKey]['carrier_list'] = $product['carrier_list'];
|
||||
} else {
|
||||
$orderPackage[$id_address][$dateJoinKey]['carrier_list'] = array_intersect($orderPackage[$id_address][$dateJoinKey]['carrier_list'], $product['carrier_list']);
|
||||
}
|
||||
if (!isset($orderPackage[$id_address][$dateJoinKey]['warehouse_list'])) {
|
||||
$orderPackage[$id_address][$dateJoinKey]['warehouse_list'] = $package['warehouse_list'];
|
||||
}
|
||||
if (!isset($orderPackage[$id_address][$dateJoinKey]['id_warehouse'])) {
|
||||
$orderPackage[$id_address][$dateJoinKey]['id_warehouse'] = $package['id_warehouse'];
|
||||
}
|
||||
if (isset($package['id_carrier'])) {
|
||||
if (!isset($orderPackage[$id_address][$dateJoinKey]['id_carrier'])) {
|
||||
$orderPackage[$id_address][$dateJoinKey]['id_carrier'] = $package['id_carrier'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$product['date_from'] = $cartRoom['date_from'];
|
||||
$product['date_to'] = $cartRoom['date_to'];
|
||||
$product['total_wt'] = $cartRoom['total_price_tax_incl'];
|
||||
$product['total'] = $cartRoom['total_price_tax_excl'];
|
||||
$product['cart_quantity'] = $cartRoom['cart_quantity'];
|
||||
$product['price_wt'] = $cartRoom['total_price_tax_incl'] / $cartRoom['cart_quantity'];
|
||||
$product['price'] = $cartRoom['total_price_tax_excl'] / $cartRoom['cart_quantity'];
|
||||
$orderPackage[$id_address][$dateJoinKey]['product_list'][] = $product;
|
||||
$orderPackage[$id_address][$idHotel]['product_list'][] = $product;
|
||||
$orderPackage[$id_address][$idHotel]['id_hotel'] = $idHotel;
|
||||
if (!isset($orderPackage[$id_address][$idHotel]['id_hotel'])) {
|
||||
$orderPackage[$id_address][$idHotel]['id_hotel'] = $productInfo['id_hotel'];
|
||||
}
|
||||
if (!isset($orderPackage[$id_address][$idHotel]['carrier_list'])) {
|
||||
$orderPackage[$id_address][$idHotel]['carrier_list'] = $product['carrier_list'];
|
||||
} else {
|
||||
$orderPackage[$id_address][$idHotel]['carrier_list'] = array_intersect($orderPackage[$id_address][$idHotel]['carrier_list'], $product['carrier_list']);
|
||||
}
|
||||
if (!isset($orderPackage[$id_address][$idHotel]['warehouse_list'])) {
|
||||
$orderPackage[$id_address][$idHotel]['warehouse_list'] = $package['warehouse_list'];
|
||||
}
|
||||
if (!isset($orderPackage[$id_address][$idHotel]['id_warehouse'])) {
|
||||
$orderPackage[$id_address][$idHotel]['id_warehouse'] = $package['id_warehouse'];
|
||||
}
|
||||
if (isset($package['id_carrier'])) {
|
||||
if (!isset($orderPackage[$id_address][$idHotel]['id_carrier'])) {
|
||||
$orderPackage[$id_address][$idHotel]['id_carrier'] = $package['id_carrier'];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -2434,16 +2379,14 @@ class CartCore extends ObjectModel
|
||||
if ($selectedServiceProducts = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart($this->id, $product['id_product'], 0, 0, 0, 0, 0, 0, null, null)) {
|
||||
$array = array();
|
||||
foreach($selectedServiceProducts as $selectedProduct) {
|
||||
$dateJoinKey = $selectedProduct['id_hotel'].'-'.strtotime($selectedProduct['date_from']).strtotime($selectedProduct['date_to']);
|
||||
if (isset($array[$dateJoinKey])) {
|
||||
$array[$dateJoinKey]['total_price_tax_excl'] += $selectedProduct['total_price_tax_excl'];
|
||||
$array[$dateJoinKey]['total_price_tax_incl'] += $selectedProduct['total_price_tax_incl'];
|
||||
if (isset($array[$selectedProduct['id_hotel']])) {
|
||||
$array[$selectedProduct['id_hotel']]['quantity'] += $selectedProduct['quantity'];
|
||||
$array[$selectedProduct['id_hotel']]['total_price_tax_excl'] += $selectedProduct['total_price_tax_excl'];
|
||||
$array[$selectedProduct['id_hotel']]['total_price_tax_incl'] += $selectedProduct['total_price_tax_incl'];
|
||||
} else {
|
||||
$array[$dateJoinKey] = array(
|
||||
'id_hotel' => $selectedProduct['id_hotel'],
|
||||
$array[$selectedProduct['id_hotel']] = array(
|
||||
'quantity' => 0,
|
||||
'date_from' => $selectedProduct['date_from'],
|
||||
'date_to' => $selectedProduct['date_to'],
|
||||
'id_hotel' => $selectedProduct['id_hotel'],
|
||||
'total_price_tax_excl' => $selectedProduct['total_price_tax_excl'],
|
||||
'total_price_tax_incl' => $selectedProduct['total_price_tax_incl'],
|
||||
);
|
||||
@@ -2453,40 +2396,37 @@ class CartCore extends ObjectModel
|
||||
$selectedProduct['date_from'],
|
||||
$selectedProduct['date_to']
|
||||
);
|
||||
$array[$dateJoinKey]['quantity'] += ($selectedProduct['quantity'] * $numDays);
|
||||
$array[$selectedProduct['id_hotel']]['quantity'] += ($selectedProduct['quantity'] * $numDays);
|
||||
} else {
|
||||
$array[$dateJoinKey]['quantity'] += $selectedProduct['quantity'];
|
||||
$array[$selectedProduct['id_hotel']]['quantity'] += $selectedProduct['quantity'];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
foreach($array as $dateJoinKey => $selectedProduct) {
|
||||
foreach($array as $selectedProduct) {
|
||||
$product['cart_quantity'] = $selectedProduct['quantity'];
|
||||
$product['total'] = $selectedProduct['total_price_tax_excl'];
|
||||
$product['total_wt'] = $selectedProduct['total_price_tax_incl'];
|
||||
$product['price_wt'] = $selectedProduct['total_price_tax_incl'] / $product['cart_quantity'];
|
||||
$product['price'] = $selectedProduct['total_price_tax_excl'] / $product['cart_quantity'];
|
||||
$product['price_wt'] = $selectedProduct['unit_price_tax_incl'];
|
||||
$product['id_hotel'] = $selectedProduct['id_hotel'];
|
||||
$product['date_from'] = $selectedProduct['date_from'];
|
||||
$product['date_to'] = $selectedProduct['date_to'];
|
||||
$orderPackage[$id_address][$dateJoinKey]['product_list'][] = $product;
|
||||
if (!isset($orderPackage[$id_address][$dateJoinKey]['id_hotel'])) {
|
||||
$orderPackage[$id_address][$dateJoinKey]['id_hotel'] = $selectedProduct['id_hotel'];
|
||||
$orderPackage[$id_address][$selectedProduct['id_hotel']]['product_list'][] = $product;
|
||||
if (!isset($orderPackage[$id_address][$selectedProduct['id_hotel']]['id_hotel'])) {
|
||||
$orderPackage[$id_address][$selectedProduct['id_hotel']]['id_hotel'] = $selectedProduct['id_hotel'];
|
||||
}
|
||||
if (!isset($orderPackage[$id_address][$dateJoinKey]['carrier_list'])) {
|
||||
$orderPackage[$id_address][$dateJoinKey]['carrier_list'] = $product['carrier_list'];
|
||||
if (!isset($orderPackage[$id_address][$selectedProduct['id_hotel']]['carrier_list'])) {
|
||||
$orderPackage[$id_address][$selectedProduct['id_hotel']]['carrier_list'] = $product['carrier_list'];
|
||||
} else {
|
||||
$orderPackage[$id_address][$dateJoinKey]['carrier_list'] = array_intersect($orderPackage[$id_address][$dateJoinKey]['carrier_list'], $product['carrier_list']);
|
||||
$orderPackage[$id_address][$selectedProduct['id_hotel']]['carrier_list'] = array_intersect($orderPackage[$id_address][$selectedProduct['id_hotel']]['carrier_list'], $product['carrier_list']);
|
||||
}
|
||||
if (!isset($orderPackage[$id_address][$dateJoinKey]['warehouse_list'])) {
|
||||
$orderPackage[$id_address][$dateJoinKey]['warehouse_list'] = $package['warehouse_list'];
|
||||
if (!isset($orderPackage[$id_address][$selectedProduct['id_hotel']]['warehouse_list'])) {
|
||||
$orderPackage[$id_address][$selectedProduct['id_hotel']]['warehouse_list'] = $package['warehouse_list'];
|
||||
}
|
||||
if (!isset($orderPackage[$id_address][$dateJoinKey]['id_warehouse'])) {
|
||||
$orderPackage[$id_address][$dateJoinKey]['id_warehouse'] = $package['id_warehouse'];
|
||||
if (!isset($orderPackage[$id_address][$selectedProduct['id_hotel']]['id_warehouse'])) {
|
||||
$orderPackage[$id_address][$selectedProduct['id_hotel']]['id_warehouse'] = $package['id_warehouse'];
|
||||
}
|
||||
if (isset($package['id_carrier'])) {
|
||||
if (!isset($orderPackage[$id_address][$dateJoinKey]['id_carrier'])) {
|
||||
$orderPackage[$id_address][$dateJoinKey]['id_carrier'] = $package['id_carrier'];
|
||||
if (!isset($orderPackage[$id_address][$selectedProduct['id_hotel']]['id_carrier'])) {
|
||||
$orderPackage[$id_address][$selectedProduct['id_hotel']]['id_carrier'] = $package['id_carrier'];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2525,28 +2465,28 @@ class CartCore extends ObjectModel
|
||||
}
|
||||
}
|
||||
|
||||
$hotelAndDateWisePackageList = array();
|
||||
$hotelWisePackageList = array();
|
||||
$numHotels = 0;
|
||||
|
||||
|
||||
if (!empty($serviceProducts)) {
|
||||
foreach ($serviceProducts as $id_address => $packagesByHotels) {
|
||||
foreach ($packagesByHotels as $packageByHotel) {
|
||||
$hotelAndDateWisePackageList[$id_address][] = $packageByHotel;
|
||||
$hotelWisePackageList[$id_address][] = $packageByHotel;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($orderPackage as $id_address => $packageByAddress) {
|
||||
$numHotels += count($packageByAddress);
|
||||
foreach ($packageByAddress as $id_package => $package) {
|
||||
$hotelAndDateWisePackageList[$id_address][] = $package;
|
||||
$hotelWisePackageList[$id_address][] = $package;
|
||||
}
|
||||
}
|
||||
// add sevice products as new package if there are multiple hotels in cart
|
||||
// if ($numHotels > 1 || count($serviceProducts) > 1) {
|
||||
// foreach ($serviceProducts as $productsByAddress) {
|
||||
// if (isset($orderPackage[$id_address])) {
|
||||
// $hotelAndDateWisePackageList[$id_address][] = array(
|
||||
// $hotelWisePackageList[$id_address][] = array(
|
||||
// 'product_list' => $productsByAddress['products'],
|
||||
// 'carrier_list' => $productsByAddress['carrier_list'],
|
||||
// 'warehouse_list' => $productsByAddress['warehouse_list'],
|
||||
@@ -2559,13 +2499,13 @@ class CartCore extends ObjectModel
|
||||
// } else if (!empty($serviceProducts)) {
|
||||
// $serviceProductsIdAddress = array_keys($serviceProducts)[0];
|
||||
// $productsByAddress = array_shift($serviceProducts);
|
||||
// if (isset($hotelAndDateWisePackageList[$serviceProductsIdAddress])) {
|
||||
// $hotelAndDateWisePackageList[$serviceProductsIdAddress][0]['product_list'] = array_merge(
|
||||
// $hotelAndDateWisePackageList[$serviceProductsIdAddress][0]['product_list'],
|
||||
// if (isset($hotelWisePackageList[$serviceProductsIdAddress])) {
|
||||
// $hotelWisePackageList[$serviceProductsIdAddress][0]['product_list'] = array_merge(
|
||||
// $hotelWisePackageList[$serviceProductsIdAddress][0]['product_list'],
|
||||
// $productsByAddress['products']
|
||||
// );
|
||||
// } else {
|
||||
// $hotelAndDateWisePackageList[$id_address][] = array(
|
||||
// $hotelWisePackageList[$id_address][] = array(
|
||||
// 'product_list' => $productsByAddress['products'],
|
||||
// 'carrier_list' => $productsByAddress['carrier_list'],
|
||||
// 'warehouse_list' => $productsByAddress['warehouse_list'],
|
||||
@@ -2575,7 +2515,7 @@ class CartCore extends ObjectModel
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
$final_package_list = $hotelAndDateWisePackageList;
|
||||
$final_package_list = $hotelWisePackageList;
|
||||
// END $package_list hotel wise
|
||||
$cache[$cache_key] = $final_package_list;
|
||||
return $final_package_list;
|
||||
|
||||
@@ -772,9 +772,8 @@ abstract class PaymentModuleCore extends Module
|
||||
$maxOverbookingCount = 0;
|
||||
foreach ($order->product_list as $product) {
|
||||
$idProduct = $product['id_product'];
|
||||
if ($product['booking_product']
|
||||
&& $cartBookingData = $objCartBookingData->getCartInfoIdCartIdProduct($this->context->cart->id, $idProduct, $product['date_from'], $product['date_to'])
|
||||
) {
|
||||
$cartBookingData = $objCartBookingData->getOnlyCartBookingData($this->context->cart->id, $this->context->cart->id_guest, $idProduct);
|
||||
if ($cartBookingData) {
|
||||
foreach ($cartBookingData as $bookingInfo) {
|
||||
$objCartBookingData = new HotelCartBookingData($bookingInfo['id']);
|
||||
$objCartBookingData->id_order = $order->id;
|
||||
@@ -987,8 +986,8 @@ abstract class PaymentModuleCore extends Module
|
||||
$product['id_product'],
|
||||
isset($product['id_hotel']) ? $product['id_hotel'] : 0,
|
||||
0,
|
||||
$product['date_from'],
|
||||
$product['date_to'],
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
null,
|
||||
|
||||
@@ -154,6 +154,9 @@ class OrderConfirmationControllerCore extends FrontController
|
||||
|
||||
if (!empty($orderProducts)) {
|
||||
foreach ($orderProducts as $type_key => $type_value) {
|
||||
if (in_array($type_value['product_id'], $processed_product)) {
|
||||
continue;
|
||||
}
|
||||
$processed_product[] = $type_value['product_id'];
|
||||
|
||||
$product = new Product($type_value['product_id'], false, $this->context->language->id);
|
||||
@@ -362,6 +365,13 @@ class OrderConfirmationControllerCore extends FrontController
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($cart_htl_data)) {
|
||||
$this->context->smarty->assign('cart_htl_data', $cart_htl_data);
|
||||
}
|
||||
if (!empty($cart_service_products)) {
|
||||
$this->context->smarty->assign('cart_service_products', $cart_service_products);
|
||||
}
|
||||
}
|
||||
if (!$objCartOrder->hasInvoice()) {
|
||||
$orders_has_invoice = 0;
|
||||
@@ -385,13 +395,6 @@ class OrderConfirmationControllerCore extends FrontController
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($cart_htl_data)) {
|
||||
$this->context->smarty->assign('cart_htl_data', $cart_htl_data);
|
||||
}
|
||||
if (!empty($cart_service_products)) {
|
||||
$this->context->smarty->assign('cart_service_products', $cart_service_products);
|
||||
}
|
||||
|
||||
$this->context->smarty->assign('orderTotalInfo', $orderTotalInfo);
|
||||
$this->context->smarty->assign('orders_has_invoice', $orders_has_invoice);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user