diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index bba787f92..0bc65f53a 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -508,8 +508,6 @@ abstract class PaymentModuleCore extends Module $order = $order_list[$key]; if (!$order_creation_failed && isset($order->id)) { - // first set if_hotel as 0 and get the hotel id from room type info -> below - $idHotel = 0; if (!$secure_key) { $message .= '
'.Tools::displayError('Warning: the secure key is empty, check your payment account before validation'); } @@ -588,12 +586,7 @@ abstract class PaymentModuleCore extends Module if (!$product['is_virtual']) { $virtual_product &= false; } - // If id_hotel is not available then find id_hotel for sending mails hotel wise - if (!$idHotel) { - if ($roomDetail = $objRoomType->getRoomTypeInfoByIdProduct((int)$product['id_product'])) { - $idHotel = $roomDetail['id_hotel']; - } - } + if (!$product['booking_product'] && ($product['selling_preference_type'] == Product::SELLING_PREFERENCE_STANDALONE || $product['selling_preference_type'] == Product::SELLING_PREFERENCE_HOTEL_STANDALONE @@ -1015,13 +1008,18 @@ abstract class PaymentModuleCore extends Module $objServiceProductOrderDetail->id_order = $order->id; $objServiceProductOrderDetail->id_order_detail = $idOrderDetail; $objServiceProductOrderDetail->id_cart = $this->context->cart->id; - $objServiceProductOrderDetail->id_hotel = $product['id_hotel']; $objServiceProductOrderDetail->unit_price_tax_excl = $hotelProduct['unit_price_tax_excl']; $objServiceProductOrderDetail->unit_price_tax_incl = $hotelProduct['unit_price_tax_incl']; $objServiceProductOrderDetail->total_price_tax_excl = $hotelProduct['total_price_tax_excl']; $objServiceProductOrderDetail->total_price_tax_incl = $hotelProduct['total_price_tax_incl']; $objServiceProductOrderDetail->name = $hotelProduct['name']; $objServiceProductOrderDetail->option_name = $hotelProduct['option_name']; + $objServiceProductOrderDetail->id_hotel = $product['id_hotel']; + if (Validate::isLoadedObject( + $objHotelBranch = new HotelBranchInformation($product['id_hotel'], $this->context->cart->id_lang) + )) { + $objServiceProductOrderDetail->hotel_name = $objHotelBranch->hotel_name; + } $objServiceProductOrderDetail->quantity = $hotelProduct['quantity']; $objServiceProductOrderDetail->save(); @@ -1089,8 +1087,13 @@ abstract class PaymentModuleCore extends Module $objServiceProductOrderDetail->name = $product['name']; $objServiceProductOrderDetail->quantity = $serviceProduct['quantity']; if ($serviceProduct['id_hotel']) { - $objServiceProductOrderDetail->id_product_option = $serviceProduct['id_product_option']; $objServiceProductOrderDetail->id_hotel = $serviceProduct['id_hotel']; + if (Validate::isLoadedObject( + $objHotelBranch = new HotelBranchInformation($serviceProduct['id_hotel'], $this->context->cart->id_lang) + )) { + $objServiceProductOrderDetail->hotel_name = $objHotelBranch->hotel_name; + } + $objServiceProductOrderDetail->id_product_option = $serviceProduct['id_product_option']; $objServiceProductOrderDetail->option_name = $serviceProduct['option_name']; } else { $roomBookingDetail = $objBookingDetail->getRowByIdOrderIdProductInDateRange( @@ -1473,7 +1476,7 @@ abstract class PaymentModuleCore extends Module } } } - if ($idHotel && Validate::isLoadedObject($objHotel = new HotelBranchInformation($idHotel))) { + if ($idOrderHotel && Validate::isLoadedObject($objHotel = new HotelBranchInformation($idOrderHotel))) { if (Configuration::get('PS_ORDER_CONF_MAIL_TO_HOTEL_MANAGER')){ // If order currenct state is overbooking, the send overbooking email or send order confirmation email if ($isOverBookingStatus) { @@ -1505,7 +1508,7 @@ abstract class PaymentModuleCore extends Module } } if (Configuration::get('PS_ORDER_CONF_MAIL_TO_EMPLOYEE')){ - if ($htlAccesses = $objHotel->getHotelAccess($idHotel)) { + if ($htlAccesses = $objHotel->getHotelAccess($idOrderHotel)) { $data['{customer_name}'] = $this->context->customer->firstname.' '.$this->context->customer->lastname; $data['{customer_email}'] = $this->context->customer->email; diff --git a/modules/blockcart/ajax-cart.js b/modules/blockcart/ajax-cart.js index ef65d3e3b..20db0a57b 100644 --- a/modules/blockcart/ajax-cart.js +++ b/modules/blockcart/ajax-cart.js @@ -702,8 +702,9 @@ var ajaxCart = { for (aProduct in jsonData.products) { //we've called the variable aProduct because IE6 bug if this variable is called product //if product has attributes - if (parseInt(jsonData.products[aProduct]['selling_preference_type']) == SELLING_PREFERENCE_HOTEL_STANDALONE - || parseInt(jsonData.products[aProduct]['selling_preference_type']) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE + if ((parseInt(jsonData.products[aProduct]['selling_preference_type']) == SELLING_PREFERENCE_HOTEL_STANDALONE + || parseInt(jsonData.products[aProduct]['selling_preference_type']) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE) + && (typeof jsonData.products[aProduct]['hotel_wise_data'] != 'undefined' && jsonData.products[aProduct]['hotel_wise_data'].length) ) { $.each(jsonData.products[aProduct]['hotel_wise_data'], function() { if (!ids[3] || (ids[3] == this.id_hotel)) { @@ -843,9 +844,11 @@ var ajaxCart = { if (parseInt(this.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE || parseInt(this.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE ) { - $(value.hotel_wise_data).each(function(i, val) { - ajaxCart.addProductRow(value, val); - }); + if (typeof value.hotel_wise_data != 'undefined' && value.hotel_wise_data.length) { + $(value.hotel_wise_data).each(function(i, val) { + ajaxCart.addProductRow(value, val); + }); + } } else { ajaxCart.addProductRow(value); } @@ -855,7 +858,7 @@ var ajaxCart = { addProductRow: function(product, hotel_wise_data) { //if product is not in the displayed cart, add a new product's line - var productDomId = product.id + '_' + (product.idCombination ? product.idCombination : '0') + '_' + (product.idAddressDelivery ? product.idAddressDelivery : '0') + '_' + ((hotel_wise_data && hotel_wise_data.id_hotel) ? hotel_wise_data.id_hotel : '0'); + var productDomId = product.id + '_' + (product.idCombination ? product.idCombination : '0') + '_' + (product.idAddressDelivery ? product.idAddressDelivery : '0') + '_' + ((hotel_wise_data && typeof(hotel_wise_data.id_hotel) != 'undefined') ? hotel_wise_data.id_hotel : '0'); var productAttributeDomId = product.id + '_' + (product.idCombination ? product.idCombination : '0'); var productId = parseInt(product.id); @@ -870,8 +873,9 @@ var ajaxCart = { content += '
'; content += '' + name + ''; content += '
'; - if (parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE - || parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE + if ((parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE + || parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE) + && (typeof(hotel_wise_data) != 'undefined' && hotel_wise_data.length) ) { content += '
' + hotel_wise_data.hotel_name + '
'; } @@ -885,8 +889,9 @@ var ajaxCart = { content += ' '; if (product.booking_product) { content += formatCurrency(parseFloat(product.bookingData.total_room_type_amount), currency_format, currency_sign, currency_blank); - }else if (parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE - || parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE + }else if ((parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE + || parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE) + && (typeof(hotel_wise_data) != 'undefined' && hotel_wise_data.length) ) { content += formatCurrency(parseFloat(hotel_wise_data.amount), currency_format, currency_sign, currency_blank); } else { @@ -899,12 +904,13 @@ var ajaxCart = { content += '' + total_qty_txt + ':'; content += ''; content += ''; - if (product.booking_product) + if (product.booking_product) { content += product.bookingData.total_num_rooms; - else if (hotel_wise_data && hotel_wise_data.total_qty) + } else if (typeof(hotel_wise_data) != 'undefined' && hotel_wise_data.total_qty) { content += hotel_wise_data.total_qty; - else + } else { content += product.cart_quantity; + } content += ''; content += ''; content += ''; @@ -912,7 +918,7 @@ var ajaxCart = { if (typeof(product.is_gift) == 'undefined' || product.is_gift == 0) - content += ' '; + content += ' '; else content += ''; @@ -1057,8 +1063,9 @@ var ajaxCart = { if (!product.is_gift) { if (product.booking_product) { $('dt[data-id="cart_block_product_' + productDomId + '"] .price').text(formatCurrency(parseFloat(product.bookingData.total_room_type_amount), currency_format, currency_sign, currency_blank)); - } else if (parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE - || parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE + } else if ((parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE + || parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE) + && typeof(hotel_wise_data) != 'undefined' ) { $('dt[data-id="cart_block_product_' + productDomId + '"] .price').text(formatCurrency(parseFloat(hotel_wise_data.amount), currency_format, currency_sign, currency_blank)); } else { @@ -1071,9 +1078,9 @@ var ajaxCart = { if (product.booking_product) { ajaxCart.updateProductQuantity(jsonProduct, product.bookingData.total_num_rooms); } else if ((parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE - || parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE - ) - && hotel_wise_data + || parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE + ) + && typeof(hotel_wise_data) != 'undefined' && hotel_wise_data.total_qty ) { ajaxCart.updateProductQuantity(jsonProduct, hotel_wise_data.total_qty, hotel_wise_data); diff --git a/modules/blockcart/blockcart.php b/modules/blockcart/blockcart.php index c5b1b5601..e3212f394 100644 --- a/modules/blockcart/blockcart.php +++ b/modules/blockcart/blockcart.php @@ -186,6 +186,7 @@ class Blockcart extends Module $products[$key]['bookingData'] = $htlCartData[$key]; } } + $cart_rules = $params['cart']->getCartRules(); if (empty($cart_rules)) { diff --git a/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js b/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js index 04ed17343..20db0a57b 100644 --- a/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js +++ b/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js @@ -841,13 +841,14 @@ var ajaxCart = { $('.cart_block_no_products').hide(); } - if ((parseInt(this.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE - || parseInt(this.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE) - && (typeof value.hotel_wise_data != 'undefined' && value.hotel_wise_data.length) + if (parseInt(this.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE + || parseInt(this.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE ) { - $(value.hotel_wise_data).each(function(i, val) { - ajaxCart.addProductRow(value, val); - }); + if (typeof value.hotel_wise_data != 'undefined' && value.hotel_wise_data.length) { + $(value.hotel_wise_data).each(function(i, val) { + ajaxCart.addProductRow(value, val); + }); + } } else { ajaxCart.addProductRow(value); } @@ -857,7 +858,7 @@ var ajaxCart = { addProductRow: function(product, hotel_wise_data) { //if product is not in the displayed cart, add a new product's line - var productDomId = product.id + '_' + (product.idCombination ? product.idCombination : '0') + '_' + (product.idAddressDelivery ? product.idAddressDelivery : '0') + '_' + ((hotel_wise_data && hotel_wise_data.id_hotel) ? hotel_wise_data.id_hotel : '0'); + var productDomId = product.id + '_' + (product.idCombination ? product.idCombination : '0') + '_' + (product.idAddressDelivery ? product.idAddressDelivery : '0') + '_' + ((hotel_wise_data && typeof(hotel_wise_data.id_hotel) != 'undefined') ? hotel_wise_data.id_hotel : '0'); var productAttributeDomId = product.id + '_' + (product.idCombination ? product.idCombination : '0'); var productId = parseInt(product.id); @@ -872,8 +873,9 @@ var ajaxCart = { content += '
'; content += '' + name + ''; content += '
'; - if (parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE - || parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE + if ((parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE + || parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE) + && (typeof(hotel_wise_data) != 'undefined' && hotel_wise_data.length) ) { content += '
' + hotel_wise_data.hotel_name + '
'; } @@ -887,8 +889,9 @@ var ajaxCart = { content += ' '; if (product.booking_product) { content += formatCurrency(parseFloat(product.bookingData.total_room_type_amount), currency_format, currency_sign, currency_blank); - }else if (parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE - || parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE + }else if ((parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE + || parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE) + && (typeof(hotel_wise_data) != 'undefined' && hotel_wise_data.length) ) { content += formatCurrency(parseFloat(hotel_wise_data.amount), currency_format, currency_sign, currency_blank); } else { @@ -901,12 +904,13 @@ var ajaxCart = { content += '' + total_qty_txt + ':'; content += ''; content += ''; - if (product.booking_product) + if (product.booking_product) { content += product.bookingData.total_num_rooms; - else if (hotel_wise_data && hotel_wise_data.total_qty) + } else if (typeof(hotel_wise_data) != 'undefined' && hotel_wise_data.total_qty) { content += hotel_wise_data.total_qty; - else + } else { content += product.cart_quantity; + } content += ''; content += ''; content += ''; @@ -914,7 +918,7 @@ var ajaxCart = { if (typeof(product.is_gift) == 'undefined' || product.is_gift == 0) - content += ' '; + content += ' '; else content += ''; @@ -1059,8 +1063,9 @@ var ajaxCart = { if (!product.is_gift) { if (product.booking_product) { $('dt[data-id="cart_block_product_' + productDomId + '"] .price').text(formatCurrency(parseFloat(product.bookingData.total_room_type_amount), currency_format, currency_sign, currency_blank)); - } else if (parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE - || parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE + } else if ((parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE + || parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE) + && typeof(hotel_wise_data) != 'undefined' ) { $('dt[data-id="cart_block_product_' + productDomId + '"] .price').text(formatCurrency(parseFloat(hotel_wise_data.amount), currency_format, currency_sign, currency_blank)); } else { @@ -1073,9 +1078,9 @@ var ajaxCart = { if (product.booking_product) { ajaxCart.updateProductQuantity(jsonProduct, product.bookingData.total_num_rooms); } else if ((parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE - || parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE - ) - && hotel_wise_data + || parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE + ) + && typeof(hotel_wise_data) != 'undefined' && hotel_wise_data.total_qty ) { ajaxCart.updateProductQuantity(jsonProduct, hotel_wise_data.total_qty, hotel_wise_data);