Fixed: cart issues while product actions and refund mails issues

This commit is contained in:
Sumit Panwar
2025-03-29 18:29:49 +05:30
parent 813a25b32f
commit b7d4116fa2
4 changed files with 67 additions and 51 deletions

View File

@@ -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 .= '<br />'.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;

View File

@@ -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 += '<div class="product-name">';
content += '<a href="' + product.link + '" title="' + product.name + '" class="cart_block_product_name">' + name + '</a>';
content += '</div>';
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 += '<div class="hotel-name">' + hotel_wise_data.hotel_name + '</div>';
}
@@ -885,8 +889,9 @@ var ajaxCart = {
content += '<span class="price product_info_data">&nbsp;';
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 += '<span class="product_info_label">' + total_qty_txt + ':</span>';
content += '<span class="quantity-formated">';
content += '<span class="quantity product_info_data">';
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 += '</span>';
content += '</span>';
content += '</div>';
@@ -912,7 +918,7 @@ var ajaxCart = {
if (typeof(product.is_gift) == 'undefined' || product.is_gift == 0)
content += '<span class="remove_link"><a rel="nofollow" class="ajax_cart_block_remove_link" href="' + baseUri + '?controller=cart&amp;delete=1&amp;id_product=' + productId + '&amp;token=' + static_token + (product.hasAttributes ? '&amp;ipa=' + parseInt(product.idCombination) : '') + (hotel_wise_data && hotel_wise_data.id_hotel ? '&amp;id_hotel=' + parseInt(hotel_wise_data.id_hotel) : '') + '">&nbsp;</a></span>';
content += '<span class="remove_link"><a rel="nofollow" class="ajax_cart_block_remove_link" href="' + baseUri + '?controller=cart&amp;delete=1&amp;id_product=' + productId + '&amp;token=' + static_token + (product.hasAttributes ? '&amp;ipa=' + parseInt(product.idCombination) : '') + (typeof(hotel_wise_data) != 'undefined' && hotel_wise_data && hotel_wise_data.id_hotel ? '&amp;id_hotel=' + parseInt(hotel_wise_data.id_hotel) : '') + '">&nbsp;</a></span>';
else
content += '<span class="remove_link"></span>';
@@ -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);

View File

@@ -186,6 +186,7 @@ class Blockcart extends Module
$products[$key]['bookingData'] = $htlCartData[$key];
}
}
$cart_rules = $params['cart']->getCartRules();
if (empty($cart_rules)) {

View File

@@ -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 += '<div class="product-name">';
content += '<a href="' + product.link + '" title="' + product.name + '" class="cart_block_product_name">' + name + '</a>';
content += '</div>';
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 += '<div class="hotel-name">' + hotel_wise_data.hotel_name + '</div>';
}
@@ -887,8 +889,9 @@ var ajaxCart = {
content += '<span class="price product_info_data">&nbsp;';
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 += '<span class="product_info_label">' + total_qty_txt + ':</span>';
content += '<span class="quantity-formated">';
content += '<span class="quantity product_info_data">';
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 += '</span>';
content += '</span>';
content += '</div>';
@@ -914,7 +918,7 @@ var ajaxCart = {
if (typeof(product.is_gift) == 'undefined' || product.is_gift == 0)
content += '<span class="remove_link"><a rel="nofollow" class="ajax_cart_block_remove_link" href="' + baseUri + '?controller=cart&amp;delete=1&amp;id_product=' + productId + '&amp;token=' + static_token + (product.hasAttributes ? '&amp;ipa=' + parseInt(product.idCombination) : '') + (hotel_wise_data && hotel_wise_data.id_hotel ? '&amp;id_hotel=' + parseInt(hotel_wise_data.id_hotel) : '') + '">&nbsp;</a></span>';
content += '<span class="remove_link"><a rel="nofollow" class="ajax_cart_block_remove_link" href="' + baseUri + '?controller=cart&amp;delete=1&amp;id_product=' + productId + '&amp;token=' + static_token + (product.hasAttributes ? '&amp;ipa=' + parseInt(product.idCombination) : '') + (typeof(hotel_wise_data) != 'undefined' && hotel_wise_data && hotel_wise_data.id_hotel ? '&amp;id_hotel=' + parseInt(hotel_wise_data.id_hotel) : '') + '">&nbsp;</a></span>';
else
content += '<span class="remove_link"></span>';
@@ -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);