Updated: When a service or room is deleted from the order, it will now also be removed from the cart.
This commit is contained in:
@@ -109,7 +109,7 @@
|
||||
</td>
|
||||
<td>{displayWtPriceWithCurrency price=$room['feature_price_tax_excl'] currency=$currency}</td>
|
||||
<td>
|
||||
{if (isset($room['extra_demands']) && $room['extra_demands']) || (isset($room['additional_service']) && $room['additional_service'])}
|
||||
{if (isset($room['selected_demands']) && $room['selected_demands']) || (isset($room['selected_services']) && $room['selected_services'])}
|
||||
<a href="#" data-toggle="modal" data-target="#rooms_type_extra_demands_{$room['id']}">
|
||||
{displayWtPriceWithCurrency price=($room['demand_price'] + $room['additional_service_price'] + $room['additional_services_auto_add_price'])|escape:'html':'UTF-8' currency=$currency}
|
||||
</a>
|
||||
@@ -118,7 +118,7 @@
|
||||
{/if}
|
||||
</td>
|
||||
<td class="text-right">
|
||||
{if (isset($room['extra_demands']) && $room['extra_demands']) || (isset($room['additional_service']) && $room['additional_service'])}
|
||||
{if (isset($room['selected_demands']) && $room['selected_demands']) || (isset($room['selected_services']) && $room['selected_services'])}
|
||||
{displayWtPriceWithCurrency price=($room['amt_with_qty'] + $room['additional_services_auto_add_price'] + $room['demand_price'] + $room['additional_service_price'])|escape:'html':'UTF-8' currency=$currency}
|
||||
{else}
|
||||
{displayWtPriceWithCurrency price=$room['amt_with_qty']|escape:'html':'UTF-8' currency=$currency}
|
||||
@@ -166,7 +166,13 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<p><span class="pull-right extra_demand_option_price">{if isset($roomDemand['adv_option']) && $roomDemand['adv_option']}{convertPrice price = $roomDemand['adv_option'][$idGlobalDemand]['price']|escape:'html':'UTF-8'}{else}{convertPrice price = $roomDemand['price']|escape:'html':'UTF-8'}{/if}</span></p>
|
||||
<p><span class="pull-right extra_demand_option_price">
|
||||
{if isset($roomDemand['adv_option']) && $roomDemand['adv_option']}
|
||||
{convertPrice price = $roomDemand['adv_option'][$demand['id_option']]['price']|escape:'html':'UTF-8'}
|
||||
{else}
|
||||
{convertPrice price = $roomDemand['price']|escape:'html':'UTF-8'}
|
||||
{/if}
|
||||
</span></p>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -302,6 +302,31 @@ class AdminCartsControllerCore extends AdminController
|
||||
$product['image'] = (isset($image['id_image']) ? ImageManager::thumbnail(_PS_IMG_DIR_.'p/'.$image_product->getExistingImgPath().'.jpg', 'product_mini_'.(int)$product['id_product'].(isset($product['id_product_attribute']) ? '_'.(int)$product['id_product_attribute'] : '').'.jpg', 45, 'jpg') : '--');
|
||||
}
|
||||
|
||||
// by webkul to show rooms available in the cart
|
||||
$cartHtlData = array();
|
||||
$objHotelCartBookingData = new HotelCartBookingData();
|
||||
$objHotelRoomType = new HotelRoomType();
|
||||
if ($cartHtlData = $objHotelCartBookingData->getCartFormatedBookinInfoByIdCart((int) $cart->id)) {
|
||||
foreach ($cartHtlData as $key => $value) {
|
||||
$cartHtlData[$key]['room_type_info'] = $objHotelRoomType->getRoomTypeInfoByIdProduct($value['id_product']);
|
||||
if (isset($value['selected_services']) && $value['selected_services']) {
|
||||
foreach ($value['selected_services'] as $service) {
|
||||
if ($service['id_cart'] != $value['id_cart']) {
|
||||
if ($tax_calculation_method == PS_TAX_EXC) {
|
||||
$total_price += ($service['quantity'] * $service['total_price_tax_excl']);
|
||||
$total_products += ($service['quantity'] * $service['total_price_tax_excl']);
|
||||
} else {
|
||||
$total_price += ($service['quantity'] * $service['total_price_tax_incl']);
|
||||
$total_products += ($service['quantity'] * $service['total_price_tax_incl']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$cartHtlData = array();
|
||||
}
|
||||
|
||||
$helper = new HelperKpi();
|
||||
$helper->id = 'box-kpi-cart';
|
||||
$helper->icon = 'icon-shopping-cart';
|
||||
@@ -310,17 +335,6 @@ class AdminCartsControllerCore extends AdminController
|
||||
$helper->subtitle = sprintf($this->l('Cart #%06d', null, null, false), $cart->id);
|
||||
$helper->value = Tools::displayPrice($total_price, $currency);
|
||||
$kpi = $helper->generate();
|
||||
// by webkul to show rooms available in the cart
|
||||
$cartHtlData = array();
|
||||
$objHotelCartBookingData = new HotelCartBookingData();
|
||||
$objHotelRoomType = new HotelRoomType();
|
||||
if ($cartHtlData = $objHotelCartBookingData->getCartFormatedBookinInfoByIdCart((int) $cart->id)) {
|
||||
foreach ($cartHtlData as $key => $value) {
|
||||
$cartHtlData[$key]['room_type_info'] = $objHotelRoomType->getRoomTypeInfoByIdProduct($value['id_product']);
|
||||
}
|
||||
} else {
|
||||
$cartHtlData = array();
|
||||
}
|
||||
//end
|
||||
$this->tpl_view_vars = array(
|
||||
'cart_htl_data' => $cartHtlData,//by webkul hotel rooms in order data
|
||||
|
||||
@@ -5442,6 +5442,15 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$idHotelBooking
|
||||
);
|
||||
|
||||
//This is added to remove the services from the cart along with room deletion process.
|
||||
$objHotelCartBookingData = new HotelCartBookingData();
|
||||
$roomHtlCartInfo = $objHotelCartBookingData->getRoomRowByIdProductIdRoomInDateRange(
|
||||
$objBookingDetail->id_cart,
|
||||
$objBookingDetail->id_product,
|
||||
$objBookingDetail->date_from,
|
||||
$objBookingDetail->date_to,
|
||||
$objBookingDetail->id_room
|
||||
);
|
||||
|
||||
/*$totalProductPriceBeforeTE = $order_detail->total_price_tax_excl;
|
||||
$totalProductPriceBeforeTI = $order_detail->total_price_tax_incl;*/
|
||||
@@ -5476,6 +5485,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$res &= $order_detail->update();
|
||||
}
|
||||
// update order detail for selected aditional services
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
|
||||
foreach ($selectedAdditonalServices['additional_services'] as $service) {
|
||||
$serviceOrderDetail = new OrderDetail($service['id_order_detail']);
|
||||
|
||||
@@ -5496,6 +5506,21 @@ class AdminOrdersControllerCore extends AdminController
|
||||
// Save order detail
|
||||
$res &= $serviceOrderDetail->update();
|
||||
}
|
||||
|
||||
if (isset($roomHtlCartInfo['id'])) {
|
||||
if ($id_room_type_service_product_cart_detail = $objRoomTypeServiceProductCartDetail->alreadyExists(
|
||||
$service['id_product'],
|
||||
$service['id_cart'],
|
||||
$roomHtlCartInfo['id']
|
||||
)) {
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail((int) $id_room_type_service_product_cart_detail);
|
||||
$serviceQuantity = $objRoomTypeServiceProductCartDetail->quantity;
|
||||
if ($objRoomTypeServiceProductCartDetail->delete()) {
|
||||
$objCart = new Cart($service['id_cart']);
|
||||
$objCart->updateQty((int)abs($serviceQuantity), $service['id_product'], null, false, 'down');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*End*/
|
||||
|
||||
@@ -5574,7 +5599,9 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$objBookingDetail->id_product,
|
||||
$objBookingDetail->id_room,
|
||||
$objBookingDetail->date_from,
|
||||
$objBookingDetail->date_to
|
||||
$objBookingDetail->date_to,
|
||||
1,
|
||||
1
|
||||
);
|
||||
|
||||
$objBookingDetail->delete();
|
||||
@@ -6493,8 +6520,31 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$quantity = $objRoomTypeServiceProductOrderDetail->quantity;
|
||||
$res = true;
|
||||
$objHotelBookingDetail = new HotelBookingDetail($objRoomTypeServiceProductOrderDetail->id_htl_booking_detail);
|
||||
$idServiceProduct = $objRoomTypeServiceProductOrderDetail->id_product;
|
||||
$objHotelCartBookingData = new HotelCartBookingData();
|
||||
$roomHtlCartInfo = $objHotelCartBookingData->getRoomRowByIdProductIdRoomInDateRange(
|
||||
$objHotelBookingDetail->id_cart,
|
||||
$objHotelBookingDetail->id_product,
|
||||
$objHotelBookingDetail->date_from,
|
||||
$objHotelBookingDetail->date_to,
|
||||
$objHotelBookingDetail->id_room
|
||||
);
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
|
||||
|
||||
if ($res &= $objRoomTypeServiceProductOrderDetail->delete()) {
|
||||
if (isset($roomHtlCartInfo['id'])) {
|
||||
if ($id_room_type_service_product_cart_detail = $objRoomTypeServiceProductCartDetail->alreadyExists(
|
||||
$idServiceProduct,
|
||||
$objRoomTypeServiceProductOrderDetail->id_cart,
|
||||
$roomHtlCartInfo['id']
|
||||
)) {
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail($id_room_type_service_product_cart_detail);
|
||||
if ($objRoomTypeServiceProductCartDetail->delete()) {
|
||||
$objCart = new Cart($objRoomTypeServiceProductOrderDetail->id_cart);
|
||||
$objCart->updateQty((int)abs($quantity), $objRoomTypeServiceProductOrderDetail->id_product, null, false, 'down');
|
||||
}
|
||||
}
|
||||
}
|
||||
$order = new Order($objRoomTypeServiceProductOrderDetail->id_order);
|
||||
if ($quantity >= $objOrderDetail->product_quantity) {
|
||||
$objOrderDetail->delete();
|
||||
|
||||
@@ -346,7 +346,8 @@ class HotelCartBookingData extends ObjectModel
|
||||
$idRoom = 0,
|
||||
$dateFrom = 0,
|
||||
$dateTo = 0,
|
||||
$updPsCart = 1
|
||||
$updPsCart = 1,
|
||||
$excludeOrdered = 0
|
||||
) {
|
||||
$where = '1';
|
||||
if ($idCart) {
|
||||
@@ -365,7 +366,9 @@ class HotelCartBookingData extends ObjectModel
|
||||
$where .= ' AND `date_to`=\''.pSQL($dateTo).'\'';
|
||||
}
|
||||
// we have to delete only rows which order is not created
|
||||
$where .= ' AND `id_order`= 0';
|
||||
if (!$excludeOrdered) {
|
||||
$where .= ' AND `id_order`= 0';
|
||||
}
|
||||
// If rooms is deleting from cart the we need to delete the ps_cart quantity of the product from table
|
||||
// if product will delete the prestashop will handle
|
||||
$numRooms = 0;
|
||||
|
||||
@@ -217,7 +217,7 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
|
||||
|
||||
$idLang = Context::getContext()->language->id;
|
||||
|
||||
$sql = 'SELECT rscd.`id_product`, rscd.`quantity`, cbd.`id_cart`, cbd.`id` as `htl_cart_booking_id` ,
|
||||
$sql = 'SELECT rscd.`id_product`, rscd.`quantity`, cbd.`id_cart`, rscd.`id_cart` as service_id_cart, cbd.`id` as `htl_cart_booking_id` ,
|
||||
cbd.`id_product` as `room_type_id_product`, cbd.`adults`, cbd.`children`, cbd.`date_from`, cbd.`date_to`';
|
||||
if (!$getTotalPrice) {
|
||||
$sql .= ', pl.`name`, cbd.`id_guest`, cbd.`id_customer`, p.`auto_add_to_cart`, p.`price_addition_type`,
|
||||
@@ -233,7 +233,8 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
|
||||
$sql .= ' LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
|
||||
ON (pl.`id_product` = p.`id_product` AND pl.`id_lang` = '.(int)$idLang.')';
|
||||
}
|
||||
$sql .= ' WHERE 1';
|
||||
|
||||
$sql .= ' WHERE 1 AND rscd.`id_product`!=0';
|
||||
|
||||
if (!is_null($autoAddToCart)) {
|
||||
$sql .= ' AND p.`auto_add_to_cart` = '. (int)$autoAddToCart;
|
||||
@@ -334,6 +335,7 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
|
||||
'name' => $product['name'],
|
||||
'quantity' => $product['quantity'],
|
||||
'auto_add_to_cart' => $product['auto_add_to_cart'],
|
||||
'id_cart' => $product['service_id_cart'],
|
||||
'allow_multiple_quantity' => $product['allow_multiple_quantity'],
|
||||
'price_addition_type' => $product['price_addition_type'],
|
||||
'price_calculation_method' => $product['price_calculation_method'],
|
||||
@@ -449,6 +451,7 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
|
||||
'quantity' => $product['quantity'],
|
||||
'auto_add_to_cart' => $product['auto_add_to_cart'],
|
||||
'allow_multiple_quantity' => $product['allow_multiple_quantity'],
|
||||
'id_cart' => $product['service_id_cart'],
|
||||
'price_addition_type' => $product['price_addition_type'],
|
||||
'price_calculation_method' => $product['price_calculation_method'],
|
||||
'unit_price_tax_excl' => ($objRoomTypeServiceProductPrice->getServicePrice(
|
||||
|
||||
@@ -247,6 +247,7 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel
|
||||
'id_order_detail' => $product['id_order_detail'],
|
||||
'id_product' => $product['id_product'],
|
||||
'name' => $product['name'],
|
||||
'id_cart' => $product['id_cart'],
|
||||
'quantity' => $product['quantity'],
|
||||
'allow_multiple_quantity' => $product['product_allow_multiple_quantity'],
|
||||
'max_quantity' => $product['max_quantity'],
|
||||
@@ -272,6 +273,7 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel
|
||||
'id_order_detail' => $product['id_order_detail'],
|
||||
'id_product' => $product['id_product'],
|
||||
'name' => $product['name'],
|
||||
'id_cart' => $product['id_cart'],
|
||||
'quantity' => $product['quantity'],
|
||||
'allow_multiple_quantity' => $product['product_allow_multiple_quantity'],
|
||||
'max_quantity' => $product['max_quantity'],
|
||||
@@ -314,4 +316,4 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel
|
||||
// delete entry from order detail table.
|
||||
return parent::delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user