From 4199e40098c33c37326376986817d171128ee4bd Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Thu, 26 Feb 2026 12:13:20 +0530 Subject: [PATCH 01/34] Added functionality for selecting the selling type in a single product with multiple types. --- .../normal_products/informations.tpl | 82 ++++++- .../controllers/orders/helpers/view/view.tpl | 36 ++- classes/Cart.php | 133 +++++++---- classes/PaymentModule.php | 212 ++++++++++++++++-- classes/Product.php | 77 ++++++- classes/order/Order.php | 81 ++++++- classes/order/OrderDetail.php | 2 +- classes/order/OrderInvoice.php | 23 +- classes/pdf/HTMLTemplateInvoice.php | 59 ++++- controllers/admin/AdminCartsController.php | 32 ++- .../admin/AdminNormalProductsController.php | 158 +++++-------- controllers/admin/AdminOrdersController.php | 198 ++++++++++++---- controllers/front/CartController.php | 122 +++++----- .../front/OrderConfirmationController.php | 92 ++++---- controllers/front/OrderDetailController.php | 87 ++++--- controllers/front/ParentOrderController.php | 35 ++- controllers/front/ProductController.php | 14 +- modules/blockcart/blockcart.php | 55 ++--- .../classes/HotelCartBookingData.php | 84 +++---- .../js/modules/blockcart/ajax-cart.js | 157 ++++++++----- .../modules/blockcart/blockcart.tpl | 20 +- .../modules/blockcart/cartrow.tpl | 16 +- .../hotel-reservation-theme/order-detail.tpl | 49 +++- 23 files changed, 1256 insertions(+), 568 deletions(-) diff --git a/admin/themes/default/template/controllers/normal_products/informations.tpl b/admin/themes/default/template/controllers/normal_products/informations.tpl index 2000a8f8c..ad77a39b0 100644 --- a/admin/themes/default/template/controllers/normal_products/informations.tpl +++ b/admin/themes/default/template/controllers/normal_products/informations.tpl @@ -230,7 +230,7 @@ {* Code For Standard product working *} - {*
+
-
*} -
selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE)}style="display:none;"{/if}> +
+
selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE)}style="display:none;"{/if}>
{include file="controllers/products/multishop/checkbox.tpl" field="category_box" type="category_box"}
-
selling_preference_type != Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != 0)}style="display:none;"{/if}> +
selling_preference_type != Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE && $product->selling_preference_type != 0)}style="display:none;"{/if}>
{include file="controllers/products/multishop/checkbox.tpl" field="category_box" type="category_box"}
-
selling_preference_type != Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $product->selling_preference_type != 0}style="display:none;"{/if}> +
selling_preference_type != Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE && $product->selling_preference_type != 0}style="display:none;"{/if}>
{/block} {block name='blockcart_shopping_cart_hotel_name'} - {if $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE || $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE} + {if isset($hotel_wise_data.id_hotel) && $hotel_wise_data.id_hotel}
{$hotel_wise_data.hotel_name|escape:'html':'UTF-8'}
@@ -29,7 +29,7 @@ {if !isset($product.is_gift) || !$product.is_gift} {if $product.booking_product} {displayWtPrice p="`$product.bookingData.total_room_type_amount`"} - {else if $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE || $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE} + {else if isset($hotel_wise_data.id_hotel) && $hotel_wise_data.id_hotel} {if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice p="`$hotel_wise_data.total_price_tax_excl`"}{else}{displayWtPrice p="`$hotel_wise_data.total_price_tax_incl`"}{/if} {else} {if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice p="`$product.total_price_tax_excl`"}{else}{displayWtPrice p="`$product.total_price_tax_incl`"}{/if} @@ -53,10 +53,10 @@ {if $product.booking_product} {$product.bookingData['total_num_rooms']} {elseif $product.allow_multiple_quantity} - {if $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE || $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE} + {if isset($hotel_wise_data.id_hotel) && $hotel_wise_data.id_hotel} {$hotel_wise_data.total_qty} - {elseif $product.selling_preference_type == Product::SELLING_PREFERENCE_STANDALONE} - {$product.cart_quantity} + {elseif Product::isSellableAsStandalone($product.selling_preference_type)} + {$product.standalone_total_qty|intval} {/if} {/if} @@ -99,9 +99,9 @@ {/block} {else if $product.hasOptions} {block name='blockcart_shopping_cart_options'} - {if $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE || $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE} + {if isset($hotel_wise_data.id_hotel) && $hotel_wise_data.id_hotel} {assign var='options' value=$hotel_wise_data.options} - {else if $product.selling_preference_type == Product::SELLING_PREFERENCE_STANDALONE} + {else} {assign var='options' value=$product.options} {/if}
@@ -155,4 +155,4 @@ {if !isset($product.attributes_small)}{/if} {/if} -{if isset($product.attributes_small)}{/if} \ No newline at end of file +{if isset($product.attributes_small)}{/if} diff --git a/themes/hotel-reservation-theme/order-detail.tpl b/themes/hotel-reservation-theme/order-detail.tpl index 9402a240d..81fa7f340 100644 --- a/themes/hotel-reservation-theme/order-detail.tpl +++ b/themes/hotel-reservation-theme/order-detail.tpl @@ -317,14 +317,27 @@ {assign var=room_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, true)} {assign var=room_price_tax_incl value=$order->getTotalProductsWithTaxes(false, true)} - - {assign var=room_services_price_tax_excl value=($order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) + $total_demands_price_te)} - {assign var=room_services_price_tax_incl value=($order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) + $total_demands_price_ti)} + {assign var=room_services_price_tax_excl value=( + $order->getTotalProductsWithoutTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED) + + $total_demands_price_te + )} + {assign var=room_services_price_tax_incl value=( + $order->getTotalProductsWithTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED) + + $total_demands_price_ti + )} + {assign var=all_services_price_tax_incl value=$order->getTotalProductsWithTaxes(false, false)} + {assign var=all_services_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, false)} + {assign var=room_linked_services_price_tax_incl value=$order->getTotalProductsWithTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED)} + {assign var=room_linked_services_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED)} {assign var=total_tax_without_discount value=(($room_price_tax_incl - $room_price_tax_excl) + ($room_services_price_tax_incl - $room_services_price_tax_excl ))} - {assign var=total_standard_products_tax_incl value=($order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE) + $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE))} - {assign var=total_standard_products_tax_excl value=($order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE) + $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE))} + {assign var=total_standard_products_tax_incl value=( + $all_services_price_tax_incl - $room_linked_services_price_tax_incl + )} + {assign var=total_standard_products_tax_excl value=( + $all_services_price_tax_excl - $room_linked_services_price_tax_excl + )} {if isset($cart_htl_data) && $cart_htl_data} {l s='Total rooms cost'} {if $use_taxes && $display_tax_label == 1}{if $priceDisplay == 1}{l s='(tax excl.)'}{elseif $priceDisplay == 0}{l s='(tax incl.)'}{/if} {/if} @@ -350,7 +363,7 @@ {/if} - {if $total_convenience_fee_te || $total_convenience_fee_te} + {if $total_convenience_fee_te || $total_convenience_fee_ti} {l s='Total Convenience Fees'} {if $use_taxes && $display_tax_label == 1}{if $priceDisplay == 1}{l s='(tax excl.)'}{elseif $priceDisplay == 0}{l s='(tax incl.)'}{/if}{/if} @@ -726,11 +739,25 @@ {assign var=room_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, true)} {assign var=room_price_tax_incl value=$order->getTotalProductsWithTaxes(false, true)} - {assign var=room_services_price_tax_excl value=($order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) + $total_demands_price_te)} - {assign var=room_services_price_tax_incl value=($order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) + $total_demands_price_ti)} + {assign var=room_services_price_tax_excl value=( + $order->getTotalProductsWithoutTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED) + + $total_demands_price_te + )} + {assign var=room_services_price_tax_incl value=( + $order->getTotalProductsWithTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED) + + $total_demands_price_ti + )} + {assign var=all_services_price_tax_incl value=$order->getTotalProductsWithTaxes(false, false)} + {assign var=all_services_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, false)} + {assign var=room_linked_services_price_tax_incl value=$order->getTotalProductsWithTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED)} + {assign var=room_linked_services_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED)} - {assign var=total_standard_products_tax_incl value=($order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE) + $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE))} - {assign var=total_standard_products_tax_excl value=($order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE) + $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE))} + {assign var=total_standard_products_tax_incl value=( + $all_services_price_tax_incl - $room_linked_services_price_tax_incl + )} + {assign var=total_standard_products_tax_excl value=( + $all_services_price_tax_excl - $room_linked_services_price_tax_excl + )} {assign var=total_tax_without_discount value=(($room_price_tax_incl - $room_price_tax_excl) + ($room_services_price_tax_incl - $room_services_price_tax_excl) + ($total_standard_products_tax_incl - $total_standard_products_tax_excl))} @@ -759,7 +786,7 @@ {/if} - {if $total_convenience_fee_te || $total_convenience_fee_te} + {if $total_convenience_fee_te || $total_convenience_fee_ti} {l s='Total Convenience Fees'} {if $use_taxes && $display_tax_label == 1}{if $priceDisplay == 1}{l s='(tax excl.)'}{elseif $priceDisplay == 0}{l s='(tax incl.)'}{/if}{/if} From 2a86378bae57b62b39aff58d532fc178989f8479 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Fri, 27 Feb 2026 10:14:09 +0530 Subject: [PATCH 02/34] Fix price calculation in order confirmation email --- classes/Cart.php | 81 +++++---- classes/PaymentModule.php | 60 +++++-- classes/pdf/HTMLTemplateInvoice.php | 80 ++++++++- classes/pdf/HTMLTemplateOrderSlip.php | 14 +- .../WebserviceSpecificManagementBookings.php | 10 +- controllers/admin/AdminImportController.php | 6 +- controllers/front/GuestTrackingController.php | 35 ++-- modules/blockcart/ajax-cart.js | 157 +++++++++++------- modules/blockcart/blockcart.tpl | 21 ++- modules/blockcart/cartrow.tpl | 12 +- .../AdminHotelRoomsBookingController.php | 4 +- 11 files changed, 321 insertions(+), 159 deletions(-) diff --git a/classes/Cart.php b/classes/Cart.php index cc5d94173..e936c663c 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -1791,42 +1791,59 @@ class CartCore extends ObjectModel } } else if ($canSellWithHotel) { - if ($type == Cart::ONLY_ROOM_SERVICES - || $type == Cart::ONLY_CONVENIENCE_FEE - || $type == Cart::ONLY_ROOM_SERVICES_WITHOUT_AUTO_ADD - || $type == Cart::ONLY_ROOM_SERVICES_WITHOUT_CONVENIENCE_FEE - || $type == Cart::ONLY_ROOM_SERVICES_WITH_AUTO_ADD_WITHOUT_CONVENIENCE_FEE - ) { - $servicePorducts = $objServiceProductCartDetail->getServiceProductsInCart( - $this->id, - [], - 0, - null, - null, - (int)$product['id_product'] - ); - } elseif ($type == Cart::ONLY_STANDALONE_PRODUCTS) { - $servicePorducts = $objServiceProductCartDetail->getServiceProductsInCart( - $this->id, - [], - null, - 0, - null, - (int)$product['id_product'] - ); - } else { - $servicePorducts = $objServiceProductCartDetail->getServiceProductsInCart( - $this->id, - [], - 0, - null, - null, - (int)$product['id_product'] - ); + $isRoomServiceTotalType = in_array($type, array( + Cart::ONLY_ROOM_SERVICES, + Cart::ONLY_CONVENIENCE_FEE, + Cart::ONLY_ROOM_SERVICES_WITHOUT_AUTO_ADD, + Cart::ONLY_ROOM_SERVICES_WITHOUT_CONVENIENCE_FEE, + Cart::ONLY_ROOM_SERVICES_WITH_AUTO_ADD_WITHOUT_CONVENIENCE_FEE, + )); + $id_hotel = null; + $id_hotel_cart_booking = null; + if ($param_product) { + if (isset($product['id_hotel']) && (int)$product['id_hotel']) { + $id_hotel = (int)$product['id_hotel']; + } + if (isset($product['id_hotel_cart_booking']) && (int)$product['id_hotel_cart_booking']) { + $id_hotel_cart_booking = (int)$product['id_hotel_cart_booking']; + } } + $servicePorducts = $objServiceProductCartDetail->getServiceProductsInCart( + $this->id, + [], + null, + null, + null, + (int)$product['id_product'] + ); + if ($servicePorducts) { foreach ($servicePorducts as $servicePorduct) { + if ($param_product) { + if ($id_hotel_cart_booking !== null + && (int)$servicePorduct['id_hotel_cart_booking'] !== $id_hotel_cart_booking + ) { + continue; + } + if ($id_hotel_cart_booking === null + && $id_hotel !== null + && ( + !empty($servicePorduct['id_hotel_cart_booking']) + || (int)$servicePorduct['id_hotel'] !== $id_hotel + ) + ) { + continue; + } + } + if ($isRoomServiceTotalType && empty($servicePorduct['id_hotel_cart_booking'])) { + continue; + } + if ($type == Cart::ONLY_STANDALONE_PRODUCTS + && !empty($servicePorduct['id_hotel_cart_booking']) + ) { + continue; + } if ($with_taxes) { $priceAdd = $servicePorduct['total_price_tax_incl']; } else { diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 3af3b70dc..e39aa34b6 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -541,6 +541,7 @@ abstract class PaymentModuleCore extends Module $product_var_tpl_list = array(); $orderServiceProducts = array(); + $processedServiceProductCartIds = array(); $objProduct = new Product(); foreach ($order->product_list as $product) { @@ -591,11 +592,11 @@ abstract class PaymentModuleCore extends Module } if ( - !$product['booking_product'] + !$product['booking_product'] && !$product['id_hotel_cart_booking'] && ( Product::isSellableAsStandalone($product['selling_preference_type']) || Product::isSellableWithHotel($product['selling_preference_type']) - ) + ) ) { $cover_image_arr = $objProduct->getCover($product['id_product']); @@ -613,7 +614,8 @@ abstract class PaymentModuleCore extends Module null, $product['id_product'] ); - + $standaloneServiceProducts = array(); + $hotelServiceProducts = array(); foreach ($serviceProducts as $serviceProduct) { $orderServiceProducts[] = array_merge($product_var_tpl, $serviceProduct); } @@ -1402,28 +1404,52 @@ abstract class PaymentModuleCore extends Module $normal_products_data_txt = $this->getEmailTemplateContent('service_product_data_text.tpl', Mail::TYPE_TEXT, $orderServiceProducts); // get order total information html/txt files + // room-related selling types: + // 1: with room type, 3: hotel+room, 6: standalone+room, 7: hotel+room+standalone + $roomRelatedSellingTypes = array( + Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, + Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, + Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, + Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, + ); + // total room price - $room_price_tax_excl = $order->getTotalProductsWithoutTaxes(false, true) + $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM); - $room_price_tax_incl = $order->getTotalProductsWithTaxes(false, true) + $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM); + $room_auto_with_room_tax_excl = 0; + $room_auto_with_room_tax_incl = 0; + foreach ($roomRelatedSellingTypes as $sellingType) { + $room_auto_with_room_tax_excl += $order->getTotalProductsWithoutTaxes(false, false, $sellingType, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM); + $room_auto_with_room_tax_incl += $order->getTotalProductsWithTaxes(false, false, $sellingType, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM); + } + $room_price_tax_excl = $order->getTotalProductsWithoutTaxes(false, true) + $room_auto_with_room_tax_excl; + $room_price_tax_incl = $order->getTotalProductsWithTaxes(false, true) + $room_auto_with_room_tax_incl; $room_tax = ($room_price_tax_incl - $room_price_tax_excl); // extra services - $additional_service_price_tax_excl = ($order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 0) + $cart_booking_data['total_extra_demands_te']); - $additional_service_price_tax_incl = ($order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 0) + $cart_booking_data['total_extra_demands_ti']); + $additional_service_price_tax_excl = (float) $cart_booking_data['total_extra_demands_te']; + $additional_service_price_tax_incl = (float) $cart_booking_data['total_extra_demands_ti']; + foreach ($roomRelatedSellingTypes as $sellingType) { + $additional_service_price_tax_excl += $order->getTotalProductsWithoutTaxes(false, false, $sellingType, 0, Product::PRICE_ADDITION_TYPE_INDEPENDENT); + $additional_service_price_tax_incl += $order->getTotalProductsWithTaxes(false, false, $sellingType, 0, Product::PRICE_ADDITION_TYPE_INDEPENDENT); + } $additional_service_tax = ($additional_service_price_tax_incl - $additional_service_price_tax_excl); // convenience fee price - $total_convenience_fee_ti = $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT); - $total_convenience_fee_te = $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT); + $total_convenience_fee_ti = 0; + $total_convenience_fee_te = 0; + foreach ($roomRelatedSellingTypes as $sellingType) { + $total_convenience_fee_ti += $order->getTotalProductsWithTaxes(false, false, $sellingType, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT); + $total_convenience_fee_te += $order->getTotalProductsWithoutTaxes(false, false, $sellingType, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT); + } $total_convenience_fee_tax = $total_convenience_fee_ti - $total_convenience_fee_te; // service products - $standalone_products_price_tax_excl = $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE); - $standalone_products_price_tax_incl = $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE); - $hotel_standalone_products_price_tax_excl = $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE); - $hotel_standalone_products_price_tax_incl = $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE); - - $service_products_tax = ($standalone_products_price_tax_incl + $hotel_standalone_products_price_tax_incl) - ($standalone_products_price_tax_excl + $hotel_standalone_products_price_tax_excl); + $all_services_price_tax_incl = $order->getTotalProductsWithTaxes(false, false); + $all_services_price_tax_excl = $order->getTotalProductsWithoutTaxes(false, false); + $room_linked_services_price_tax_incl = $order->getTotalProductsWithTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED); + $room_linked_services_price_tax_excl = $order->getTotalProductsWithoutTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED); + $total_standard_products_tax_incl = $all_services_price_tax_incl - $room_linked_services_price_tax_incl; + $total_standard_products_tax_excl = $all_services_price_tax_excl - $room_linked_services_price_tax_excl; + $service_products_tax = $total_standard_products_tax_incl - $total_standard_products_tax_excl; $total_order_tax = $room_tax + $additional_service_tax + $total_convenience_fee_tax + $service_products_tax; @@ -1440,12 +1466,12 @@ abstract class PaymentModuleCore extends Module 'total_convenience_fee_te' => Tools::displayPrice($total_convenience_fee_te, $this->context->currency, false), 'total_convenience_fee_tax' => Tools::displayPrice($total_convenience_fee_tax, $this->context->currency, false), 'service_products_price_tax_excl' => Tools::displayPrice( - ($standalone_products_price_tax_excl + $hotel_standalone_products_price_tax_excl), + $total_standard_products_tax_excl, $this->context->currency, false ), 'service_products_price_tax_incl' => Tools::displayPrice( - ($standalone_products_price_tax_incl + $hotel_standalone_products_price_tax_incl), + $total_standard_products_tax_incl, $this->context->currency, false ), diff --git a/classes/pdf/HTMLTemplateInvoice.php b/classes/pdf/HTMLTemplateInvoice.php index 4b4754ca8..23839e4e8 100644 --- a/classes/pdf/HTMLTemplateInvoice.php +++ b/classes/pdf/HTMLTemplateInvoice.php @@ -679,17 +679,81 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate $footer['room_price_tax_incl'] = $this->order->getTotalProductsWithTaxes(false, true, null, null, null, $idsOrderDetail); foreach ($roomTypeSellingPreferenceTypes as $sellingPreferenceType) { - $footer['room_price_tax_excl'] += $this->order->getTotalProductsWithoutTaxes(false, false, $sellingPreferenceType, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM, $idsOrderDetail); - $footer['room_price_tax_incl'] += $this->order->getTotalProductsWithTaxes(false, false, $sellingPreferenceType, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM, $idsOrderDetail); - $footer['additional_service_price_tax_excl'] += $this->order->getTotalProductsWithoutTaxes(false, false, $sellingPreferenceType, 0, null, $idsOrderDetail); - $footer['additional_service_price_tax_incl'] += $this->order->getTotalProductsWithTaxes(false, false, $sellingPreferenceType, 0, null, $idsOrderDetail); - $footer['total_convenience_fee_te'] += $this->order->getTotalProductsWithoutTaxes(false, false, $sellingPreferenceType, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT, $idsOrderDetail); - $footer['total_convenience_fee_ti'] += $this->order->getTotalProductsWithTaxes(false, false, $sellingPreferenceType, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT, $idsOrderDetail); + $footer['room_price_tax_excl'] += $this->order->getTotalProductsWithoutTaxes( + false, + false, + $sellingPreferenceType, + 1, + Product::PRICE_ADDITION_TYPE_WITH_ROOM, + $idsOrderDetail, + Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED + ); + $footer['room_price_tax_incl'] += $this->order->getTotalProductsWithTaxes( + false, + false, + $sellingPreferenceType, + 1, + Product::PRICE_ADDITION_TYPE_WITH_ROOM, + $idsOrderDetail, + Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED + ); + $footer['additional_service_price_tax_excl'] += $this->order->getTotalProductsWithoutTaxes( + false, + false, + $sellingPreferenceType, + 0, + null, + $idsOrderDetail, + Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED + ); + $footer['additional_service_price_tax_incl'] += $this->order->getTotalProductsWithTaxes( + false, + false, + $sellingPreferenceType, + 0, + null, + $idsOrderDetail, + Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED + ); + $footer['total_convenience_fee_te'] += $this->order->getTotalProductsWithoutTaxes( + false, + false, + $sellingPreferenceType, + 1, + Product::PRICE_ADDITION_TYPE_INDEPENDENT, + $idsOrderDetail, + Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED + ); + $footer['total_convenience_fee_ti'] += $this->order->getTotalProductsWithTaxes( + false, + false, + $sellingPreferenceType, + 1, + Product::PRICE_ADDITION_TYPE_INDEPENDENT, + $idsOrderDetail, + Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED + ); } foreach ($serviceSellingPreferenceTypes as $sellingPreferenceType) { - $footer['service_products_price_tax_excl'] += $this->order->getTotalProductsWithoutTaxes(false, false, $sellingPreferenceType, false, false, $idsOrderDetail); - $footer['service_products_price_tax_incl'] += $this->order->getTotalProductsWithTaxes(false, false, $sellingPreferenceType, false, false, $idsOrderDetail); + $footer['service_products_price_tax_excl'] += $this->order->getTotalProductsWithoutTaxes( + false, + false, + $sellingPreferenceType, + false, + false, + $idsOrderDetail, + Order::SERVICE_PRODUCT_CONTEXT_NON_ROOM + ); + $footer['service_products_price_tax_incl'] += $this->order->getTotalProductsWithTaxes( + false, + false, + $sellingPreferenceType, + false, + false, + $idsOrderDetail, + Order::SERVICE_PRODUCT_CONTEXT_NON_ROOM + ); } $footer['additional_service_price_tax_excl'] += $totalDemandsPriceTE; diff --git a/classes/pdf/HTMLTemplateOrderSlip.php b/classes/pdf/HTMLTemplateOrderSlip.php index 16396243f..0c2a50c86 100644 --- a/classes/pdf/HTMLTemplateOrderSlip.php +++ b/classes/pdf/HTMLTemplateOrderSlip.php @@ -286,7 +286,7 @@ class HTMLTemplateOrderSlipCore extends HTMLTemplateInvoice $order_detail = array_filter($this->order->products, function($v) { return ((isset($v['is_booking_product']) && $v['is_booking_product']) || ((isset($v['product_auto_add']) && $v['product_auto_add']) - && $v['selling_preference_type'] == Product::SELLING_PREFERENCE_WITH_ROOM_TYPE + && Product::isSellableWithRoomType($v['selling_preference_type']) && $v['product_price_addition_type'] == ProductCore::PRICE_ADDITION_TYPE_WITH_ROOM) ); }); @@ -347,10 +347,14 @@ class HTMLTemplateOrderSlipCore extends HTMLTemplateInvoice // - 'total_amount' $breakdown = array(); $order_detail = array_filter($this->order->products, function($v) { - return (!$v['is_booking_product'] && ( - $v['selling_preference_type'] == Product::SELLING_PREFERENCE_STANDALONE - || $v['selling_preference_type'] == Product::SELLING_PREFERENCE_HOTEL_STANDALONE - )); + return ( + !$v['is_booking_product'] + && empty($v['id_htl_booking']) + && ( + Product::isSellableAsStandalone($v['selling_preference_type']) + || Product::isSellableWithHotel($v['selling_preference_type']) + ) + ); }); $details = $this->order->getProductTaxesDetails($order_detail, false); diff --git a/classes/webservice/WebserviceSpecificManagementBookings.php b/classes/webservice/WebserviceSpecificManagementBookings.php index 10e52dab0..bb9e3be7d 100644 --- a/classes/webservice/WebserviceSpecificManagementBookings.php +++ b/classes/webservice/WebserviceSpecificManagementBookings.php @@ -1015,7 +1015,15 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We } } - $serviceProductPrice = $objOrder->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE); + $serviceProductPrice = $objOrder->getTotalProductsWithTaxes( + false, + false, + null, + null, + null, + [], + Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED + ); if ($demands = $objHotelBookingDemands->getExtraDemandsTaxesDetails($objOrder->id)) { $demandsPrice = array_sum(array_column($demands, 'total_price_tax_excl')); // Adding the tax diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index d2819efca..cf130c6e3 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -1901,7 +1901,7 @@ class AdminImportControllerCore extends AdminController } $objServiceProduct = new Product($idServiceProduct); - if (Product::SELLING_PREFERENCE_WITH_ROOM_TYPE == $objServiceProduct->selling_preference_type) { + if (Product::isSellableWithRoomType($objServiceProduct->selling_preference_type)) { $objRoomTypeServiceProduct->addRoomProductLink( $objServiceProduct->id, $product->id, @@ -2329,12 +2329,12 @@ class AdminImportControllerCore extends AdminController $info['shop'] = explode($this->multiple_value_separator, $info['shop']); RoomTypeServiceProduct::deleteRoomProductLink($product->id); - if (Product::SELLING_PREFERENCE_WITH_ROOM_TYPE == $product->selling_preference_type) { + if (Product::isSellableWithRoomType($product->selling_preference_type)) { $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); if (isset($info['id_room_types']) && $info['id_room_types']) { $objRoomTypeServiceProduct->addRoomProductLink( $product->id, - $product->id_room_types, + $info['id_room_types'], RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE ); } diff --git a/controllers/front/GuestTrackingController.php b/controllers/front/GuestTrackingController.php index 596d54185..fd684953b 100644 --- a/controllers/front/GuestTrackingController.php +++ b/controllers/front/GuestTrackingController.php @@ -497,7 +497,7 @@ class GuestTrackingControllerCore extends FrontController $value['avg_price_diff_tax_excl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_excl'] - $value['product_price_tax_excl'], 6)); $value['avg_price_diff_tax_incl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_incl'] - $value['product_price_tax_incl'], 6)); } - } elseif ($type_value['selling_preference_type'] == Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) { + } elseif (Product::isSellableWithRoomType($type_value['selling_preference_type'])) { if ($type_value['product_auto_add'] && $type_value['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT) { $total_convenience_fee_ti += $objServiceProductOrderDetail->getRoomTypeServiceProducts( $idOrder, @@ -524,7 +524,10 @@ class GuestTrackingControllerCore extends FrontController 1 ); } - } else if ($type_value['selling_preference_type'] == Product::SELLING_PREFERENCE_HOTEL_STANDALONE) { + } else if ( + Product::isSellableWithHotel($type_value['selling_preference_type']) + || Product::isSellableAsStandalone($type_value['selling_preference_type']) + ) { $cover_image_arr = $product->getCover($type_value['product_id']); if (!empty($cover_image_arr)) { @@ -532,21 +535,21 @@ class GuestTrackingControllerCore extends FrontController } else { $type_value['cover_img'] = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code.'-default', 'small_default'); } - $hotelProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($idOrder, $type_value['id_order_detail'], $type_value['product_id']); - foreach ($hotelProducts as $hotelProduct) { - $hotelServiceProducts[] = array_merge($type_value, $hotelProduct); - } - } else if ($type_value['selling_preference_type'] == Product::SELLING_PREFERENCE_STANDALONE) { - $cover_image_arr = $product->getCover($type_value['product_id']); - if (!empty($cover_image_arr)) { - $type_value['cover_img'] = $this->context->link->getImageLink($product->link_rewrite, $product->id.'-'.$cover_image_arr['id_image'], 'small_default'); - } else { - $type_value['cover_img'] = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code.'-default', 'small_default'); - } - $standaloneProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($idOrder, $type_value['id_order_detail'], $type_value['product_id']); - foreach ($standaloneProducts as $standaloneProduct) { - $standaloneServiceProducts[] = array_merge($type_value, $standaloneProduct); + $serviceProducts = $objServiceProductOrderDetail->getServiceProductsInOrder( + $idOrder, + $type_value['id_order_detail'], + $type_value['product_id'] + ); + foreach ($serviceProducts as $serviceProduct) { + $isStandaloneRow = empty($serviceProduct['id_hotel']) && empty($serviceProduct['id_htl_booking_detail']); + $isHotelRow = !empty($serviceProduct['id_hotel']) && empty($serviceProduct['id_htl_booking_detail']); + + if ($isHotelRow && Product::isSellableWithHotel($type_value['selling_preference_type'])) { + $hotelServiceProducts[] = array_merge($type_value, $serviceProduct); + } elseif ($isStandaloneRow && Product::isSellableAsStandalone($type_value['selling_preference_type'])) { + $standaloneServiceProducts[] = array_merge($type_value, $serviceProduct); + } } } } diff --git a/modules/blockcart/ajax-cart.js b/modules/blockcart/ajax-cart.js index ca2ad2695..85c34b47e 100644 --- a/modules/blockcart/ajax-cart.js +++ b/modules/blockcart/ajax-cart.js @@ -127,6 +127,51 @@ var ajaxCart = { dateFormat: 'DD-MM-YYYY', dateFormatFull: 'DD-MM-YYYY HH:mm:ss', nb_total_products: 0, + getSellingPreferenceChannels: function(sellingPreferenceType) { + var channels = { + with_room_type: false, + with_hotel: false, + standalone: false + }; + switch (parseInt(sellingPreferenceType)) { + case SELLING_PREFERENCE_WITH_ROOM_TYPE: + channels.with_room_type = true; + break; + case SELLING_PREFERENCE_HOTEL_STANDALONE: + channels.with_hotel = true; + break; + case SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE: + channels.with_room_type = true; + channels.with_hotel = true; + break; + case SELLING_PREFERENCE_STANDALONE: + channels.standalone = true; + break; + case SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE: + channels.with_hotel = true; + channels.standalone = true; + break; + case SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE: + channels.with_room_type = true; + channels.standalone = true; + break; + case SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE: + channels.with_room_type = true; + channels.with_hotel = true; + channels.standalone = true; + break; + } + return channels; + }, + isSellableWithRoomType: function(sellingPreferenceType) { + return this.getSellingPreferenceChannels(sellingPreferenceType).with_room_type; + }, + isSellableWithHotel: function(sellingPreferenceType) { + return this.getSellingPreferenceChannels(sellingPreferenceType).with_hotel; + }, + isSellableAsStandalone: function(sellingPreferenceType) { + return this.getSellingPreferenceChannels(sellingPreferenceType).standalone; + }, _overrideButtonsInThePage: function () { //for every 'add' buttons... $(document).off('click', '.ajax_add_to_cart_button').on('click', '.ajax_add_to_cart_button', function (e) { @@ -703,15 +748,13 @@ var ajaxCart = { //try to know if the current product is still in the new list var stayInTheCart = false; + var isHotelRow = (typeof ids[3] != 'undefined' && parseInt(ids[3], 10) > 0); 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) - && (typeof jsonData.products[aProduct]['hotel_wise_data'] != 'undefined' && jsonData.products[aProduct]['hotel_wise_data'].length) - ) { + if (isHotelRow && (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)) { + if (ids[3] == this.id_hotel) { stayInTheCart = true; } }); @@ -835,25 +878,37 @@ var ajaxCart = { $(jsonData.products).each(function(key, value) { //fix ie6 bug (one more item 'undefined' in IE6) if (this.id != undefined) { - if (!this.booking_product && parseInt(this.selling_preference_type) == SELLING_PREFERENCE_WITH_ROOM_TYPE) { - return; - } - //create a container for listing the products and hide the 'no product in the cart' message (only if the cart was empty) - if ($('.cart_block:first dl.products').length == 0) { - $('.cart_block_no_products').before('
'); - $('.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 + if ( + this.booking_product + || ajaxCart.isSellableWithHotel(parseInt(this.selling_preference_type)) + || ajaxCart.isSellableAsStandalone(parseInt(this.selling_preference_type)) ) { - if (typeof value.hotel_wise_data != 'undefined') { - $(value.hotel_wise_data).each(function(i, val) { - ajaxCart.addProductRow(value, val); - }); + if ($('.cart_block:first dl.products').length == 0) { + $('.cart_block_no_products').before('
'); + $('.cart_block_no_products').hide(); + } + + var hasHotelRows = (typeof value.hotel_wise_data != 'undefined' && value.hotel_wise_data.length); + if (hasHotelRows) { + if (typeof value.hotel_wise_data != 'undefined') { + $(value.hotel_wise_data).each(function(i, val) { + ajaxCart.addProductRow(value, val); + }); + } + } + + var shouldShowStandaloneRow = this.booking_product + || ( + !ajaxCart.isSellableWithHotel(parseInt(this.selling_preference_type)) + && !ajaxCart.isSellableWithRoomType(parseInt(this.selling_preference_type)) + ) + || ( + ajaxCart.isSellableAsStandalone(parseInt(this.selling_preference_type)) + && parseInt(value.standalone_total_qty || 0, 10) > 0 + ); + if (shouldShowStandaloneRow) { + ajaxCart.addProductRow(value); } - } else { - ajaxCart.addProductRow(value); } } }); @@ -876,10 +931,7 @@ 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) - && (typeof(hotel_wise_data) != 'undefined' && typeof(hotel_wise_data.hotel_name) != 'undefined') - ) { + if ((typeof(hotel_wise_data) != 'undefined' && typeof(hotel_wise_data.hotel_name) != 'undefined')) { content += '
' + hotel_wise_data.hotel_name + '
'; } @@ -893,10 +945,7 @@ var ajaxCart = { 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) - && (typeof(hotel_wise_data) != 'undefined') - ) { + } else if (typeof(hotel_wise_data) != 'undefined') { content += formatCurrency(parseFloat(hotel_wise_data.amount), currency_format, currency_sign, currency_blank); } else { content += formatCurrency(parseFloat(product.amount), currency_format, currency_sign, currency_blank); @@ -916,7 +965,7 @@ var ajaxCart = { if (typeof(hotel_wise_data) != 'undefined' && hotel_wise_data.total_qty) { content += hotel_wise_data.total_qty; } else { - content += product.cart_quantity; + content += (typeof product.standalone_total_qty != 'undefined' ? product.standalone_total_qty : product.cart_quantity); } } content += ''; @@ -976,16 +1025,11 @@ var ajaxCart = { content += '' + price_txt + ''; content += ' '; 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 (hotel_wise_data.options !== 'undefined') { - var options = hotel_wise_data.options; - } - } else if (parseInt(product.selling_preference_type) == SELLING_PREFERENCE_STANDALONE) { - if (product.options !== 'undefined') { - var options = product.options; - } + var options = []; + if (typeof(hotel_wise_data) != 'undefined' && typeof(hotel_wise_data.options) != 'undefined') { + options = hotel_wise_data.options; + } else if (typeof(product.options) != 'undefined') { + options = product.options; } if (options !== 'undefined') { $.each(options, function(data_k, data_v) { @@ -1043,16 +1087,11 @@ var ajaxCart = { } else if (product.hasOptions) { $('dt[data-id="cart_block_product_' + productDomId + '"] .cart_prod_cont tr.product_option_row').remove(); var product_options_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 (hotel_wise_data.options !== 'undefined') { - var options = hotel_wise_data.options; - } - } else if (parseInt(product.selling_preference_type) == SELLING_PREFERENCE_STANDALONE) { - if (product.options !== 'undefined') { - var options = product.options; - } + var options = []; + if (typeof(hotel_wise_data) != 'undefined' && typeof(hotel_wise_data.options) != 'undefined') { + options = hotel_wise_data.options; + } else if (typeof(product.options) != 'undefined') { + options = product.options; } if (options !== 'undefined') { $.each(options, function(data_k, data_v) { @@ -1077,10 +1116,7 @@ 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) - && typeof(hotel_wise_data) != 'undefined' - ) { + } else if (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 { $('dt[data-id="cart_block_product_' + productDomId + '"] .price').text(formatCurrency(parseFloat(product.amount), currency_format, currency_sign, currency_blank)); @@ -1091,15 +1127,16 @@ var ajaxCart = { //cart_booking_data[key].total_num_rooms argument sent to update num of rooms instead of quantity 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 - ) - && typeof(hotel_wise_data) != 'undefined' + } else if ( + typeof(hotel_wise_data) != 'undefined' && hotel_wise_data.total_qty ) { ajaxCart.updateProductQuantity(jsonProduct, hotel_wise_data.total_qty, hotel_wise_data); } else { - ajaxCart.updateProductQuantity(jsonProduct, jsonProduct.cart_quantity); + ajaxCart.updateProductQuantity( + jsonProduct, + (typeof jsonProduct.standalone_total_qty != 'undefined' ? jsonProduct.standalone_total_qty : jsonProduct.cart_quantity) + ); } // Customized product diff --git a/modules/blockcart/blockcart.tpl b/modules/blockcart/blockcart.tpl index af73ec530..ec29d14f4 100644 --- a/modules/blockcart/blockcart.tpl +++ b/modules/blockcart/blockcart.tpl @@ -63,14 +63,15 @@
{foreach from=$products key=data_k item='product' name='myLoop'} {* only show products that are booking or global without room *} - {if $product.booking_product || ($product.selling_preference_type == Product::SELLING_PREFERENCE_STANDALONE)|| ($product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE) || ($product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE)} - {if $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE || $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE} - {if isset($product.hotel_wise_data) && $product.hotel_wise_data} - {foreach $product.hotel_wise_data as $hotel_wise_data} - {include file="./cartrow.tpl" hotel_wise_data=$hotel_wise_data} - {/foreach} - {/if} - {else} + {if $product.booking_product || Product::isSellableAsStandalone($product.selling_preference_type) || Product::isSellableWithHotel($product.selling_preference_type)} + {if isset($product.hotel_wise_data) && $product.hotel_wise_data} + {foreach $product.hotel_wise_data as $hotel_wise_data} + {include file="./cartrow.tpl" hotel_wise_data=$hotel_wise_data} + {/foreach} + {/if} + {if $product.booking_product + || (!Product::isSellableWithHotel($product.selling_preference_type) && !Product::isSellableWithRoomType($product.selling_preference_type)) + || (Product::isSellableAsStandalone($product.selling_preference_type) && $product.standalone_total_qty > 0)} {include file="./cartrow.tpl" hotel_wise_data=false} {/if} {/if} @@ -401,11 +402,13 @@ {addJsDef img_dir=$img_dir|escape:'quotes':'UTF-8'} {addJsDef generated_date=$smarty.now|intval} {addJsDef ajax_allowed=$ajax_allowed|boolval} - {addJsDef hasDeliveryAddress=(isset($cart->id_address_delivery) && $cart->id_address_delivery)} {addJsDef SELLING_PREFERENCE_WITH_ROOM_TYPE=Product::SELLING_PREFERENCE_WITH_ROOM_TYPE} {addJsDef SELLING_PREFERENCE_STANDALONE=Product::SELLING_PREFERENCE_STANDALONE} {addJsDef SELLING_PREFERENCE_HOTEL_STANDALONE=Product::SELLING_PREFERENCE_HOTEL_STANDALONE} {addJsDef SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE=Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE} + {addJsDef SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE=Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE} + {addJsDef SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE=Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE} + {addJsDef SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE=Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE} {addJsDefL name=customizationIdMessage}{l s='Customization #' mod='blockcart' js=1}{/addJsDefL} {addJsDefL name=removingLinkText}{l s='remove this product from my cart' mod='blockcart' js=1}{/addJsDefL} diff --git a/modules/blockcart/cartrow.tpl b/modules/blockcart/cartrow.tpl index e909aaacf..68d0cbc96 100644 --- a/modules/blockcart/cartrow.tpl +++ b/modules/blockcart/cartrow.tpl @@ -11,7 +11,7 @@
{/block} {block name='blockcart_shopping_cart_hotel_name'} - {if $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE || $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE} + {if Product::isSellableWithHotel($product.selling_preference_type)}
{$hotel_wise_data.hotel_name|escape:'html':'UTF-8'}
@@ -29,7 +29,7 @@ {if !isset($product.is_gift) || !$product.is_gift} {if $product.booking_product} {displayWtPrice p="`$product.bookingData.total_room_type_amount`"} - {else if $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE || $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE} + {else if Product::isSellableWithHotel($product.selling_preference_type)} {if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice p="`$hotel_wise_data.total_price_tax_excl`"}{else}{displayWtPrice p="`$hotel_wise_data.total_price_tax_incl`"}{/if} {else} {if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice p="`$product.total_price_tax_excl`"}{else}{displayWtPrice p="`$product.total_price_tax_incl`"}{/if} @@ -53,9 +53,9 @@ {if $product.booking_product} {$product.bookingData['total_num_rooms']} {elseif $product.allow_multiple_quantity} - {if $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE || $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE} + {if Product::isSellableWithHotel($product.selling_preference_type)} {$hotel_wise_data.total_qty} - {elseif $product.selling_preference_type == Product::SELLING_PREFERENCE_STANDALONE} + {elseif Product::isSellableAsStandalone($product.selling_preference_type)} {$product.cart_quantity} {/if} {/if} @@ -99,9 +99,9 @@ {/block} {else if $product.hasOptions} {block name='blockcart_shopping_cart_options'} - {if $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE || $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE} + {if Product::isSellableWithHotel($product.selling_preference_type)} {assign var='options' value=$hotel_wise_data.options} - {else if $product.selling_preference_type == Product::SELLING_PREFERENCE_STANDALONE} + {else if Product::isSellableAsStandalone($product.selling_preference_type)} {assign var='options' value=$product.options} {/if}
diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php index fac60d468..b86558c85 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php @@ -625,9 +625,9 @@ class AdminHotelRoomsBookingController extends ModuleAdminController if (!$product->id || !$product->active) { $this->errors[] = $this->l('This product is no longer available.'); } - if ($product->booking_product || ($product->selling_preference_type != Product::SELLING_PREFERENCE_STANDALONE)) { + if ($product->booking_product || !Product::isSellableAsStandalone($product->selling_preference_type)) { // cannot be added without room type or is a booking product. - $this->errors[] = $this->l('This product is either a room type or additional service and cannot be added thorugh this method.'); + $this->errors[] = $this->l('This product is either a room type or additional service and cannot be added through this method.'); } elseif (!$product->allow_multiple_quantity) { // check if product already exists in cart. if ($id_cart) { From 3dc7b7b1880cffe9fb62087376fd95a0f531ce52 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Fri, 27 Feb 2026 13:23:16 +0530 Subject: [PATCH 03/34] Fix update price calculation method --- .../controllers/normal_products/prices.tpl | 29 +++++---- .../_add_order_extra_services_tab_content.tpl | 15 ++++- ..._services_service_products_tab_content.tpl | 35 ++++++++--- classes/Product.php | 63 ++++++++++++++++--- .../WebserviceSpecificManagementBookings.php | 55 +++++++++------- controllers/admin/AdminCartsController.php | 10 +-- .../admin/AdminNormalProductsController.php | 11 +++- controllers/admin/AdminOrdersController.php | 36 ++++++----- .../classes/HotelHelper.php | 10 +-- .../classes/ServiceProductCartDetail.php | 39 ++++++------ .../_partials/cart_booking_demands.tpl | 17 +++-- .../_partials/service-products-list-row.tpl | 9 ++- 12 files changed, 222 insertions(+), 107 deletions(-) diff --git a/admin/themes/default/template/controllers/normal_products/prices.tpl b/admin/themes/default/template/controllers/normal_products/prices.tpl index bae5d1211..6d315a307 100644 --- a/admin/themes/default/template/controllers/normal_products/prices.tpl +++ b/admin/themes/default/template/controllers/normal_products/prices.tpl @@ -206,19 +206,24 @@ $(document).ready(function () {
{if isset($pack) && $pack->isPack($product->id)}

{l s='The sum of prices of the products in the pack is %s%s%s' sprintf=[$currency->prefix,{toolsConvertPrice price=$pack->noPackPrice($product->id)|string_format:$priceDisplayPrecisionFormat},$currency->suffix]}

{/if}
*} -
- -
- +
+ +
+ +
-
{* As no use in QloApps currently so commented *} {*
{include file="controllers/products/multishop/checkbox.tpl" field="unit_price" type="unit_price"}
diff --git a/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl b/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl index 048757a04..3dc6241f0 100644 --- a/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl +++ b/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl @@ -91,7 +91,11 @@ {$cartCurrency->sign} - {if Product::PRICE_CALCULATION_METHOD_PER_DAY == $product['price_calculation_method']} + {if Product::getPriceCalculationApplicableDays( + $product['price_calculation_method'], + $selectedRoomServiceProduct['date_from'], + $selectedRoomServiceProduct['date_to'] + ) > 1} {l s='/ night'} {/if}
@@ -132,8 +136,13 @@
diff --git a/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl b/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl index 8fb331302..4f6ce1c58 100644 --- a/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl +++ b/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl @@ -82,7 +82,11 @@
{$currencySign} - {if Product::PRICE_CALCULATION_METHOD_PER_DAY == $service.price_calculation_method} + {if Product::getPriceCalculationApplicableDays( + $service.price_calculation_method, + $additionalServices['date_from'], + $additionalServices['date_to'] + ) > 1} {l s='/ night'} {/if}
@@ -152,9 +156,13 @@
{$currencySign} - {if Product::PRICE_CALCULATION_METHOD_PER_DAY == $product['price_calculation_method']} - {l s='/ night'} - {/if} + {if Product::getPriceCalculationApplicableDays( + $product['price_calculation_method'], + $additionalServices['date_from'], + $additionalServices['date_to'] + ) > 1} + {l s='/ night'} + {/if}
@@ -191,8 +199,13 @@
@@ -286,9 +299,13 @@ {displayPrice price=$service['unit_price_tax_excl'] currency=$orderCurrency} - {if $service['price_calculation_method'] == Product::PRICE_CALCULATION_METHOD_PER_DAY} - {l s='/ night'} - {/if} + {if Product::getPriceCalculationApplicableDays( + $service['price_calculation_method'], + $additionalServices['date_from'], + $additionalServices['date_to'] + ) > 1} + {l s='/ night'} + {/if} {displayPrice price=$service['total_price_tax_excl'] currency=$orderCurrency} diff --git a/classes/Product.php b/classes/Product.php index fc962d3c0..cfb27c0ad 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -566,8 +566,15 @@ class ProductCore extends ObjectModel const PRICE_ADDITION_TYPE_WITH_ROOM = 1; const PRICE_ADDITION_TYPE_INDEPENDENT = 2; - const PRICE_CALCULATION_METHOD_PER_BOOKING = 1; - const PRICE_CALCULATION_METHOD_PER_DAY = 2; + const PRICE_CALCULATION_METHOD_PER_DAY = 1; + + const PRICE_CALCULATION_METHOD_ONLY_CHECKIN_DAY = 1; + const PRICE_CALCULATION_METHOD_ONLY_CHECKOUT_DAY = 2; + const PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY = 3; + const PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY = 4; + const PRICE_CALCULATION_METHOD_CHECKIN_AND_DURINGSTAY = 5; + const PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURINGSTAY = 6; + const PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY = 7; const STANDARD_PRODUCT_ADDRESS_PREFERENCE_CUSTOMER = 1; const STANDARD_PRODUCT_ADDRESS_PREFERENCE_HOTEL = 2; @@ -6865,12 +6872,54 @@ class ProductCore extends ObjectModel ) ); - if (Product::getProductPriceCalculation($idProduct) == Product::PRICE_CALCULATION_METHOD_PER_DAY - && $dateFrom && $dateTo - ) { - $price = $price * HotelHelper::getNumberOfDays($dateFrom, $dateTo); - } + $numdays = Product::getPriceCalculationApplicableDays( + Product::getProductPriceCalculation($idProduct), + $dateFrom, + $dateTo + ); + $price = $price * $numdays; return $price * (int)$quantity; } + + + public static function getPriceCalculationApplicableDays( + $priceCalculationMethod, + $dateFrom, + $dateTo, + $defaultDays = 1 + ) { + if (empty($dateFrom) || empty($dateTo)) { + return (int) $defaultDays; + } + + $numNights = (int) HotelHelper::getNumberOfDays($dateFrom, $dateTo); + if ($numNights <= 0) { + return (int) $defaultDays; + } + + switch ((int) $priceCalculationMethod) { + case self::PRICE_CALCULATION_METHOD_ONLY_CHECKIN_DAY: + case self::PRICE_CALCULATION_METHOD_ONLY_CHECKOUT_DAY: + return 1; + + case self::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY: + return max($numNights - 1, 1); + + case self::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY: + return 2; + + case self::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURINGSTAY: + case self::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURINGSTAY: + return $numNights; + + case self::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY: + return $numNights + 1; + + default: + return $numNights; + } + } + } + diff --git a/classes/webservice/WebserviceSpecificManagementBookings.php b/classes/webservice/WebserviceSpecificManagementBookings.php index 10e52dab0..cc67e3351 100644 --- a/classes/webservice/WebserviceSpecificManagementBookings.php +++ b/classes/webservice/WebserviceSpecificManagementBookings.php @@ -2297,10 +2297,13 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We ))) { foreach ($services as $service) { $insertedServiceProductIdOrderDetail = $objBookingDetail->getLastInsertedServiceIdOrderDetail($objOrder->id, $service['id_product']); - $numDays = 1; - if (Product::getProductPriceCalculation($service['id_product']) == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $numDays = HotelHelper::getNumberOfDays($objBookingDetail->date_from, $objBookingDetail->date_to); - } + + $numDays = Product::getPriceCalculationApplicableDays( + Product::getProductPriceCalculation($service['id_product']), + $objBookingDetail->date_from, + $objBookingDetail->date_to + ); + $totalPriceTaxExcl = Product::getServiceProductPrice( $service['id_product'], 0, @@ -2653,9 +2656,12 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We foreach ($selectedAdditonalServices[$idHotelBooking]['additional_services'] as $service) { $serviceOrderDetail = new OrderDetail($service['id_order_detail']); $cart_quantity = $service['quantity']; - if ($service['price_calculation_method'] == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $cart_quantity = $cart_quantity * $quantity; - } + $serviceApplicableDays = Product::getPriceCalculationApplicableDays( + $service['price_calculation_method'], + $dateFrom, + $dateTo + ); + $cart_quantity = $cart_quantity * $serviceApplicableDays; if ($cart_quantity >= $serviceOrderDetail->product_quantity) { $serviceOrderDetail->delete(); @@ -3169,10 +3175,11 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We $priceTaxExcl = $objServiceProductOrderDetail->total_price_tax_excl; $priceTaxIncl = $objServiceProductOrderDetail->total_price_tax_incl; $objHotelBookingDetail = new HotelBookingDetail($objServiceProductOrderDetail->id_htl_booking_detail); - $numDays = 1; - if (Product::getProductPriceCalculation($service['id_product']) == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $numDays = HotelHelper::getNumberOfDays($objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to); - } + $numDays = Product::getPriceCalculationApplicableDays( + Product::getProductPriceCalculation($service['id_product']), + $objHotelBookingDetail->date_from, + $objHotelBookingDetail->date_to + ); $quantity = $objOrderDetail->product_quantity * $numDays; if ($objServiceProductOrderDetail->delete()) { @@ -3264,10 +3271,11 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We $insertedServiceProductIdOrderDetail = $objHotelBookingDetail->getLastInsertedServiceIdOrderDetail($objOrder->id, $service['id_product']); $objOrderDetail = new OrderDetail($insertedServiceProductIdOrderDetail); - $numDays = 1; - if (Product::getProductPriceCalculation($product['id_product']) == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $numDays = HotelHelper::getNumberOfDays($objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to); - } + $numDays = Product::getPriceCalculationApplicableDays( + Product::getProductPriceCalculation($product['id_product']), + $objHotelBookingDetail->date_from, + $objHotelBookingDetail->date_to + ); $quantity = $objServiceProductCartDetail->quantity * $numDays; @@ -3687,17 +3695,18 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We $services['id_service'] = (int) $service['id_product']; $services['name'] = $service['name']; $services['quantity'] = (int) $service['quantity']; - $services['unit_price_without_tax'] = Tools::ps_round(($service['total_price_tax_excl'] / $services['quantity']), _PS_PRICE_COMPUTE_PRECISION_); + $applicableDays = Product::getPriceCalculationApplicableDays( + $service['price_calculation_method'], + $additionalService['date_from'], + $additionalService['date_to'] + ); + $unitDivisor = max(1, ((int) $services['quantity'] * (int) $applicableDays)); + $services['unit_price_without_tax'] = Tools::ps_round(($service['total_price_tax_excl'] / $unitDivisor), _PS_PRICE_COMPUTE_PRECISION_); $services['total_price_without_tax'] = Tools::ps_round(($service['total_price_tax_excl']), _PS_PRICE_COMPUTE_PRECISION_); $services['total_tax'] = Tools::ps_round(($service['total_price_tax_incl'] - $service['total_price_tax_excl']), _PS_PRICE_COMPUTE_PRECISION_); - $objProduct = new Product($service['id_product']); - $services['per_night'] = 0; - if ($objProduct->price_calculation_method == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $services['per_night'] = 1; - } - - $services['price_mode'] = (int) $objProduct->price_calculation_method; + $services['per_night'] = ((int) $applicableDays > 1) ? 1 : 0; + $services['price_mode'] = (int) $service['price_calculation_method']; $roomInfo['services'][] = $services; } } diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index f76331422..626185f1f 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -1205,10 +1205,12 @@ class AdminCartsControllerCore extends AdminController if ($serviceProducts) { foreach ($serviceProducts as $key => $servProduct) { - $numDays = 1; - if (Product::PRICE_CALCULATION_METHOD_PER_DAY == $servProduct['price_calculation_method']) { - $numDays = HotelHelper::getNumberOfDays($dateFrom, $dateTo); - } + $numDays = Product::getPriceCalculationApplicableDays( + $servProduct['price_calculation_method'], + $dateFrom, + $dateTo + ); + $serviceProducts[$key]['price_tax_exc'] = Product::getServiceProductPrice( $servProduct['id_product'], 0, diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index 43838ccc8..6827d5811 100644 --- a/controllers/admin/AdminNormalProductsController.php +++ b/controllers/admin/AdminNormalProductsController.php @@ -200,8 +200,13 @@ class AdminNormalProductsControllerCore extends AdminController Product::PRICE_ADDITION_TYPE_INDEPENDENT => $this->l('Convenience Fee') ); $priceCalculationMethod = array( - Product::PRICE_CALCULATION_METHOD_PER_BOOKING => $this->l('Add price once for the booking range'), - Product::PRICE_CALCULATION_METHOD_PER_DAY => $this->l('Add price for each day of booking') + Product::PRICE_CALCULATION_METHOD_ONLY_CHECKIN_DAY => $this->l('Only check-in day'), + Product::PRICE_CALCULATION_METHOD_ONLY_CHECKOUT_DAY => $this->l('Only check-out day'), + Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY => $this->l('Only during-stay days'), + Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY => $this->l('Check-in and check-out days'), + Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURINGSTAY => $this->l('Check-in | during-stay days'), + Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURINGSTAY => $this->l('Check-out | during-stay days'), + Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY => $this->l('Check-in | check-out | during-stay days'), ); $this->_join .= ' @@ -222,7 +227,7 @@ class AdminNormalProductsControllerCore extends AdminController LEFT JOIN `'._DB_PREFIX_.'htl_room_type` hrt ON (rsp.`id_element` = hrt.`id_product` AND rsp.`element_type` = '.(int)RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE.') '.HotelBranchInformation::addHotelRestriction(false, 'hrt'); - $this->_select .= ' IF(a.`auto_add_to_cart`, "'.$this->l('Yes').'", "'.$this->l('No').'") as auto_added, IF(a.`auto_add_to_cart`, 1, 0) as badge_success, IF(a.`show_at_front`, "'.$this->l('Yes').'", "'.$this->l('No').'") as show_at_front_txt, IF(a.`price_calculation_method` = '.(int)Product::PRICE_CALCULATION_METHOD_PER_DAY.', "'.$this->l('Per Day').'", "'.$this->l('Per Booking').'") as price_calculation_method_txt, (SELECT COUNT(hri.`id`) FROM `'._DB_PREFIX_.'htl_room_information` hri WHERE hri.`id_product` = a.`id_product`) as num_rooms, '; + $this->_select .= ' IF(a.`auto_add_to_cart`, "'.$this->l('Yes').'", "'.$this->l('No').'") as auto_added, IF(a.`auto_add_to_cart`, 1, 0) as badge_success, IF(a.`show_at_front`, "'.$this->l('Yes').'", "'.$this->l('No').'") as show_at_front_txt, CASE a.`price_calculation_method` WHEN '.Product::PRICE_CALCULATION_METHOD_ONLY_CHECKIN_DAY.' THEN "'.$this->l('Only check-in day').'" WHEN '.Product::PRICE_CALCULATION_METHOD_ONLY_CHECKOUT_DAY.' THEN "'.$this->l('Only check-out day').'" WHEN '.Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY.' THEN "'.$this->l('Only during-stay days').'" WHEN '.Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY.' THEN "'.$this->l('Check-in and check-out days').'" WHEN '.Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURINGSTAY.' THEN "'.$this->l('Check-in | during-stay days').'" WHEN '.Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURINGSTAY.' THEN "'.$this->l('Check-out | during-stay days').'" WHEN '.Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY.' THEN "'.$this->l('Check-in | check-out | during-stay days').'" ELSE "'.$this->l('Only check-in day').'" END as price_calculation_method_txt, (SELECT COUNT(hri.`id`) FROM `'._DB_PREFIX_.'htl_room_information` hri WHERE hri.`id_product` = a.`id_product`) as num_rooms, '; $this->_select .= ' COUNT(hrt.`id_product`) as products_associated, '; $this->_select .= 'shop.`name` AS `shopname`, a.`id_shop_default`, '; $this->_select .= $alias_image.'.`id_image` AS `id_image`, cl.`name` AS `name_category`, '.$alias.'.`price`, 0 AS `price_final`, a.`is_virtual`, pd.`nb_downloadable`, sav.`quantity` AS `sav_quantity`, '.$alias.'.`active`, IF(sav.`quantity`<=0, 1, 0) AS `badge_danger`'; diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 30026bcca..e9f5be74f 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -5342,10 +5342,11 @@ class AdminOrdersControllerCore extends AdminController )) { foreach ($services as $service) { $insertedServiceProductIdOrderDetail = $objBookingDetail->getLastInsertedServiceIdOrderDetail($order->id, $service['id_product']); - $numDays = 1; - if (Product::getProductPriceCalculation($service['id_product']) == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $numDays = HotelHelper::getNumberOfDays($objBookingDetail->date_from, $objBookingDetail->date_to); - } + $numDays = Product::getPriceCalculationApplicableDays( + Product::getProductPriceCalculation($service['id_product']), + $objBookingDetail->date_from, + $objBookingDetail->date_to + ); $totalPriceTaxExcl = Product::getServiceProductPrice( (int) $service['id_product'], @@ -6519,9 +6520,12 @@ class AdminOrdersControllerCore extends AdminController $serviceOrderDetail = new OrderDetail($service['id_order_detail']); $cart_quantity = $service['quantity']; - if ($service['price_calculation_method'] == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $cart_quantity = $cart_quantity * $product_quantity; - } + $serviceApplicableDays = Product::getPriceCalculationApplicableDays( + $service['price_calculation_method'], + $selectedAdditonalServices[$idHotelBooking]['date_from'], + $selectedAdditonalServices[$idHotelBooking]['date_to'] + ); + $cart_quantity = $cart_quantity * $serviceApplicableDays; if ($cart_quantity >= $serviceOrderDetail->product_quantity) { $serviceOrderDetail->delete(); } else { @@ -7702,10 +7706,11 @@ class AdminOrdersControllerCore extends AdminController $this->context->cart = $cart; $this->context->customer = new Customer($order->id_customer); - $numDays = 1; - if (Product::getProductPriceCalculation($service['id']) == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $numDays = HotelHelper::getNumberOfDays($objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to); - } + $numDays = Product::getPriceCalculationApplicableDays( + Product::getProductPriceCalculation($service['id']), + $objHotelBookingDetail->date_from, + $objHotelBookingDetail->date_to + ); $objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice(); $initialServicePrice = Product::getServiceProductPrice( @@ -8013,10 +8018,11 @@ class AdminOrdersControllerCore extends AdminController $objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice(); $cartProductProcessed = 1; - $numDays = 1; - if (Product::getProductPriceCalculation($objServiceProduct->id) == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $numDays = HotelHelper::getNumberOfDays($objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to); - } + $numDays = Product::getPriceCalculationApplicableDays( + Product::getProductPriceCalculation($objServiceProduct->id), + $objHotelBookingDetail->date_from, + $objHotelBookingDetail->date_to + ); foreach ($productList as &$product) { // This is used to get the actual quanity of the service as it is calculated incorrectly if the service is per night if ($idRoomTypeServProductCart = $objServiceProductCartDetail->alreadyExists( diff --git a/modules/hotelreservationsystem/classes/HotelHelper.php b/modules/hotelreservationsystem/classes/HotelHelper.php index a196694f5..709a9b23a 100644 --- a/modules/hotelreservationsystem/classes/HotelHelper.php +++ b/modules/hotelreservationsystem/classes/HotelHelper.php @@ -2155,7 +2155,7 @@ class HotelHelper 'price' => '250', 'auto_add_to_cart' => 1, 'show_at_front' => 0, - 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_PER_DAY, + 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY, 'price_addition_type' => Product::PRICE_ADDITION_TYPE_WITH_ROOM, 'en' => array( 'name' => 'Room Maintenance Fees', @@ -2220,7 +2220,7 @@ class HotelHelper 'price' => '50', 'auto_add_to_cart' => 0, 'show_at_front' => 1, - 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_PER_BOOKING, + 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY, 'price_addition_type' => Product::PRICE_ADDITION_TYPE_WITH_ROOM, 'en' => array( 'name' => 'Airport Shuttle', @@ -2252,7 +2252,7 @@ class HotelHelper 'price' => '200', 'auto_add_to_cart' => 0, 'show_at_front' => 1, - 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_PER_BOOKING, + 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY, 'price_addition_type' => Product::PRICE_ADDITION_TYPE_WITH_ROOM, 'en' => array( 'name' => 'Cab on Demand', @@ -2284,7 +2284,7 @@ class HotelHelper 'price' => '350', 'auto_add_to_cart' => 0, 'show_at_front' => 1, - 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_PER_DAY, + 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY, 'price_addition_type' => Product::PRICE_ADDITION_TYPE_WITH_ROOM, 'en' => array( 'name' => 'Breakfast', @@ -2316,7 +2316,7 @@ class HotelHelper 'price' => '450', 'auto_add_to_cart' => 0, 'show_at_front' => 1, - 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_PER_DAY, + 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY, 'price_addition_type' => Product::PRICE_ADDITION_TYPE_WITH_ROOM, 'en' => array( 'name' => 'Dinner', diff --git a/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php b/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php index 25a1edfcb..1c93321d9 100644 --- a/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php +++ b/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php @@ -89,11 +89,13 @@ class ServiceProductCartDetail extends ObjectModel $objServiceProductCartDetail = new ServiceProductCartDetail($product['id_service_product_cart_detail']) )) { $updateQty = $product['quantity']; - if (Product::getProductPriceCalculation($product['id_product']) == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $objHotelCartBookingData = new HotelCartBookingData($htlCartBookingId); - $numdays = HotelHelper::getNumberOfDays($objHotelCartBookingData->date_from, $objHotelCartBookingData->date_to); - $updateQty *= $numdays; - } + $objHotelCartBookingData = new HotelCartBookingData($htlCartBookingId); + $numdays = Product::getPriceCalculationApplicableDays( + Product::getProductPriceCalculation($product['id_product']), + $objHotelCartBookingData->date_from, + $objHotelCartBookingData->date_to + ); + $updateQty *= $numdays; if ($objServiceProductCartDetail->delete()) { $objCart = new Cart($product['id_cart']); if (isset(Context::getContext()->controller->controller_type)) { @@ -247,13 +249,11 @@ class ServiceProductCartDetail extends ObjectModel $product['htl_cart_booking_id'] ); } else { - $numDays = 1; - // If price type is per day but the dates are not valid. - if (($objProduct->price_calculation_method == Product::PRICE_CALCULATION_METHOD_PER_DAY) - && (!$numDays = HotelHelper::getNumberOfDays($product['date_from'], $product['date_to'])) - ) { - $numDays = 1; - } + $numDays = Product::getPriceCalculationApplicableDays( + $objProduct->price_calculation_method, + $product['date_from'], + $product['date_to'] + ); $priceTaxIncl = Product::getServiceProductPrice( $objProduct->id, @@ -455,14 +455,13 @@ class ServiceProductCartDetail extends ObjectModel } if ($objServiceProductCartDetail->save()) { - if ($objProduct->price_calculation_method == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - if (Validate::isLoadedObject($objHotelCartBooking = new HotelCartBookingData($idHtlCartData))) { - $numDays = HotelHelper::getNumberOfDays( - $objHotelCartBooking->date_from, - $objHotelCartBooking->date_to - ); - $quantity = $objServiceProductCartDetail->quantity * $numDays; - } + if (Validate::isLoadedObject($objHotelCartBooking = new HotelCartBookingData($idHtlCartData))) { + $numDays = Product::getPriceCalculationApplicableDays( + $objProduct->price_calculation_method, + $objHotelCartBooking->date_from, + $objHotelCartBooking->date_to + ); + $quantity = $objServiceProductCartDetail->quantity * $numDays; } $objCart = new Cart($idCart); diff --git a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl index f74c3b628..5a3db8aaa 100644 --- a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl +++ b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl @@ -148,12 +148,19 @@
-
- {if ($product.show_price && !isset($restricted_country_mode)) || isset($groups)} - {if !$priceDisplay}{convertPrice price=$product.price_tax_incl}{else}{convertPrice price=$product.price_tax_exc}{/if}{if $product.price_calculation_method == Product::PRICE_CALCULATION_METHOD_PER_DAY}{l s='/Night'}{/if} +
+ {if ($product.show_price && !isset($restricted_country_mode)) || isset($groups)} + + {if !$priceDisplay}{convertPrice price=$product.price_tax_incl}{else}{convertPrice price=$product.price_tax_exc}{/if} + {if Product::getPriceCalculationApplicableDays( + $product.price_calculation_method, + $cartRoom.date_from|default:'', + $cartRoom.date_to|default:'' + ) > 1}{l s='/Night'}{/if} + - {/if} -
+ {/if} +
{/foreach} {/if} diff --git a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl index 19ac25070..5a8896426 100644 --- a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl +++ b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl @@ -53,7 +53,14 @@ {if !$PS_CATALOG_MODE && !$order_date_restrict && ($service_product.show_price && !isset($restricted_country_mode))}
{block name='service_product_price'} - {if !$priceDisplay}{convertPrice price=$service_product.price_tax_incl}{else}{convertPrice price=$service_product.price_tax_exc}{/if}{if $service_product.price_calculation_method == Product::PRICE_CALCULATION_METHOD_PER_DAY}{l s='/Night'}{/if} + {if !$priceDisplay}{convertPrice price=$service_product.price_tax_incl}{else}{convertPrice price=$service_product.price_tax_exc}{/if} + {if Product::getPriceCalculationApplicableDays( + $service_product.price_calculation_method, + $service_product.date_from|default:$date_from|default:'', + $service_product.date_to|default:$date_to|default:'' + ) > 1} + {l s='/Night'} + {/if} {/block} {if $service_product.allow_multiple_quantity && $service_product.available_for_order && $service_product.max_quantity > 0}
From 37ff12c22aa0f63732753b0221da8b9b4c1ad73d Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Mon, 2 Mar 2026 12:40:00 +0530 Subject: [PATCH 04/34] Fix the issue related to price calculation on the invoice. --- .../controllers/orders/helpers/view/view.tpl | 3 ++- classes/PaymentModule.php | 6 ++---- classes/order/Order.php | 15 ++------------- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl index 9d83f4482..0053d2631 100644 --- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -902,7 +902,8 @@
- {* Assign order price *} + + {* Assign order price *} {if ($order->getTaxCalculationMethod() == $smarty.const.PS_TAX_EXC)} {assign var=order_product_price value=($order->total_products)} {assign var=order_discount_price value=$order->total_discounts_tax_excl} diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index e39aa34b6..6745a0e2d 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -1427,10 +1427,8 @@ abstract class PaymentModuleCore extends Module // extra services $additional_service_price_tax_excl = (float) $cart_booking_data['total_extra_demands_te']; $additional_service_price_tax_incl = (float) $cart_booking_data['total_extra_demands_ti']; - foreach ($roomRelatedSellingTypes as $sellingType) { - $additional_service_price_tax_excl += $order->getTotalProductsWithoutTaxes(false, false, $sellingType, 0, Product::PRICE_ADDITION_TYPE_INDEPENDENT); - $additional_service_price_tax_incl += $order->getTotalProductsWithTaxes(false, false, $sellingType, 0, Product::PRICE_ADDITION_TYPE_INDEPENDENT); - } + $additional_service_price_tax_excl += $order->getTotalProductsWithoutTaxes(false, false, null, 0, Product::PRICE_ADDITION_TYPE_INDEPENDENT, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED); + $additional_service_price_tax_incl += $order->getTotalProductsWithTaxes(false, false, null, 0, Product::PRICE_ADDITION_TYPE_INDEPENDENT,null,Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED); $additional_service_tax = ($additional_service_price_tax_incl - $additional_service_price_tax_excl); // convenience fee price diff --git a/classes/order/Order.php b/classes/order/Order.php index 5ccfe9cba..ca9ef9327 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -635,21 +635,10 @@ class OrderCore extends ObjectModel if (!$is_booking && $selling_preference_type !== null) { $sql .= ' AND od.`selling_preference_type` = '. (int)$selling_preference_type; } - if ( - !$is_booking - && $selling_preference_type !== null - && Product::isSellableWithRoomType($selling_preference_type) - && $product_auto_add !== null - ) { + if (!$is_booking && $product_auto_add !== null) { $sql .= ' AND od.`product_auto_add` = '. (int)$product_auto_add; } - if ( - !$is_booking - && $selling_preference_type !== null - && Product::isSellableWithRoomType($selling_preference_type) - && $product_auto_add == 1 - && $product_price_addition_type !== null - ) { + if (!$is_booking && $product_auto_add == 1 && $product_price_addition_type !== null) { $sql .= ' AND od.`product_price_addition_type` = '. (int)$product_price_addition_type; } From cd047d34d3a1f3780937f4b51ac0ca120fdeda18 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Mon, 2 Mar 2026 18:44:24 +0530 Subject: [PATCH 05/34] Fix service product option display based on selling type. --- .../normal_products/informations.tpl | 62 ---------- classes/Cart.php | 38 +++--- js/admin/normal_products.js | 113 ++++++++++-------- 3 files changed, 88 insertions(+), 125 deletions(-) diff --git a/admin/themes/default/template/controllers/normal_products/informations.tpl b/admin/themes/default/template/controllers/normal_products/informations.tpl index ad77a39b0..3bf54bd1b 100644 --- a/admin/themes/default/template/controllers/normal_products/informations.tpl +++ b/admin/themes/default/template/controllers/normal_products/informations.tpl @@ -614,66 +614,4 @@ var SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE = {Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE|intval}; var SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE = {Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE|intval}; var SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE = {Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE|intval}; - - function toggleAssociationFieldNames(containerSelector, shouldShow) - { - var $container = $(containerSelector); - if (shouldShow) { - $container.show('fast').find('input').each(function() { - $(this).attr('name', $(this).attr('data-name')); - $(this).removeAttr('data-name'); - }); - } else { - $container.hide('fast').find('input').each(function() { - $(this).attr('data-name', $(this).attr('name')); - $(this).removeAttr('name'); - }); - } - } - - function applySellingPreferenceUIState() - { - var sellingPreference = parseInt($('#selling_preference_type').val(), 10); - var showHotelTree = $.inArray(sellingPreference, [ - SELLING_PREFERENCE_HOTEL_STANDALONE, - SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE - ]) !== -1; - var showRoomTypeTree = $.inArray(sellingPreference, [ - 0, - SELLING_PREFERENCE_WITH_ROOM_TYPE, - SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE - ]) !== -1; - var showAutoAddToCart = $.inArray(sellingPreference, [ - 0, - SELLING_PREFERENCE_WITH_ROOM_TYPE, - SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE - ]) !== -1; - - toggleAssociationFieldNames('#associated_hotel_tree', showHotelTree); - toggleAssociationFieldNames('#associated_hotel_rooms_tree', showRoomTypeTree); - if (showAutoAddToCart) { - $('#auto_add_to_cart_container').show('fast'); - } else { - $('#auto_add_to_cart_container').hide('fast'); - $('input[name="auto_add_to_cart"]').trigger('change'); - } - $('#show_at_front_container').show('fast'); - $('#product_options').show('fast'); - } - - $(document).on('change.sellingPreferenceExtended', '#selling_preference_type', function() { - applySellingPreferenceUIState(); - }); - - $(function() { - setTimeout(function() { - applySellingPreferenceUIState(); - }, 0); - }); diff --git a/classes/Cart.php b/classes/Cart.php index e936c663c..0b2d86500 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -2483,6 +2483,9 @@ class CartCore extends ObjectModel )) { $array = array(); foreach($selectedServiceProducts as $selectedProduct) { + if (empty($selectedProduct['id_hotel_cart_booking'])) { + continue; + } if (isset($array[$selectedProduct['id_room_type_hotel']])) { $array[$selectedProduct['id_room_type_hotel']]['total_price_tax_excl'] += $selectedProduct['total_price_tax_excl']; $array[$selectedProduct['id_room_type_hotel']]['total_price_tax_incl'] += $selectedProduct['total_price_tax_incl']; @@ -2507,7 +2510,7 @@ class CartCore extends ObjectModel } } - + if ($array) { foreach($array as $selectedProduct) { $product['cart_quantity'] = $selectedProduct['quantity']; @@ -2544,19 +2547,27 @@ class CartCore extends ObjectModel } } } - if (Product::isSellableAsStandalone($product['selling_preference_type']) && !Product::isSellableWithRoomType($product['selling_preference_type'])) { - if (!isset($standaloneProduct[$id_address])) { - $standaloneProduct[$id_address] = array( - 'product_list' => array(), - 'warehouse_list' => $package['warehouse_list'], - 'carrier_list' => $product['carrier_list'], - 'id_warehouse' => $package['id_warehouse'], - 'id_carrier' => isset($package['id_carrier']) ? $package['id_carrier'] : 0 - ); + if (Product::isSellableAsStandalone($product['selling_preference_type'])) { + if ($selectedServiceProducts = $objServiceProductCartDetail->getServiceProductsInCart( + $this->id, + [], + 0, + 0, + null, + (int)$product['id_product'] + )) { + if (!isset($standaloneProduct[$id_address])) { + $standaloneProduct[$id_address] = array( + 'product_list' => array(), + 'warehouse_list' => $package['warehouse_list'], + 'carrier_list' => $product['carrier_list'], + 'id_warehouse' => $package['id_warehouse'], + 'id_carrier' => isset($package['id_carrier']) ? $package['id_carrier'] : 0 + ); + } + $productinfo = $product; + $standaloneProduct[$id_address]['product_list'][] = $product; } - $productinfo = $product; - // $productinfo['selling_preference_type'] = Product::SELLING_PREFERENCE_STANDALONE; - $standaloneProduct[$id_address]['product_list'][] = $product; } if (Product::isSellableWithHotel($product['selling_preference_type'])) { @@ -2600,7 +2611,6 @@ class CartCore extends ObjectModel // if (!empty($hotelProducts['products'])) { // foreach($hotelProducts['products'] as $hotelProduct) { $productinfo = $serviceProduct; - // $productinfo['selling_preference_type'] = Product::SELLING_PREFERENCE_HOTEL_STANDALONE; $orderPackage[$id_address][$hotelProduct['id_hotel']]['product_list'][] = $productinfo; if (!isset($orderPackage[$id_address][$hotelProduct['id_hotel']]['id_hotel'])) { $orderPackage[$id_address][$hotelProduct['id_hotel']]['id_hotel'] = $hotelProduct['id_hotel']; diff --git a/js/admin/normal_products.js b/js/admin/normal_products.js index 2e1bf00a6..9826b146f 100644 --- a/js/admin/normal_products.js +++ b/js/admin/normal_products.js @@ -547,57 +547,72 @@ product_tabs['Informations'] = new function(){ }; this.switchProductType = function(){ + function toggleAssociationFieldNames(containerSelector, shouldShow) + { + var $container = $(containerSelector); + if (shouldShow) { + $container.show('fast').find('input').each(function() { + $(this).attr('name', $(this).attr('data-name')); + $(this).removeAttr('data-name'); + }); + } else { + $container.hide('fast').find('input').each(function() { + $(this).attr('data-name', $(this).attr('name')); + $(this).removeAttr('name'); + }); + } + } + + function applySellingPreferenceUIState() + { + var sellingPreference = parseInt($('#selling_preference_type').val(), 10); + var showHotelTree = $.inArray(sellingPreference, [ + SELLING_PREFERENCE_HOTEL_STANDALONE, + SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, + SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, + SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE + ]) !== -1; + var showRoomTypeTree = $.inArray(sellingPreference, [ + 0, + SELLING_PREFERENCE_WITH_ROOM_TYPE, + SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, + SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, + SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE + ]) !== -1; + var showAutoAddToCart = $.inArray(sellingPreference, [ + 0, + SELLING_PREFERENCE_WITH_ROOM_TYPE, + SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, + SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, + SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE + ]) !== -1; + var $autoAddOff = $('#auto_add_to_cart_off'); + var $autoAddCheckedInput; + + toggleAssociationFieldNames('#associated_hotel_tree', showHotelTree); + toggleAssociationFieldNames('#associated_hotel_rooms_tree', showRoomTypeTree); + + if (showAutoAddToCart) { + $('#auto_add_to_cart_container').show('fast'); + $autoAddCheckedInput = $('input[name="auto_add_to_cart"]:checked'); + if (!$autoAddCheckedInput.length) { + $autoAddOff.prop('checked', true); + $autoAddCheckedInput = $autoAddOff; + } + } else { + $autoAddOff.prop('checked', true); + $('#auto_add_to_cart_container').hide('fast'); + $autoAddCheckedInput = $autoAddOff; + } + + $autoAddCheckedInput.trigger('change'); + $('#product_options').show('fast'); + } $('#selling_preference_type').on('change',function(){ - if (parseInt($(this).val()) == SELLING_PREFERENCE_WITH_ROOM_TYPE) { - $('#associated_hotel_tree').hide('fast').find('input').each(function() { - $(this).attr('data-name', $(this).attr('name')); - $(this).removeAttr('name'); - }); - $('#associated_hotel_rooms_tree').show('fast').find('input').each(function() { - $(this).attr('name', $(this).attr('data-name')); - $(this).removeAttr('data-name'); - }); - $('#auto_add_to_cart_container').show('fast'); - $('#show_at_front_container').show('fast'); - $('#product_options').show('fast'); - } else if (parseInt($(this).val()) == SELLING_PREFERENCE_HOTEL_STANDALONE) { - $('#associated_hotel_rooms_tree').hide('fast').find('input').each(function() { - $(this).attr('data-name', $(this).attr('name')); - $(this).removeAttr('name'); - }); - $('#associated_hotel_tree').show('fast').find('input').each(function() { - $(this).attr('name', $(this).attr('data-name')); - $(this).removeAttr('data-name'); - }); - $('#auto_add_to_cart_container').hide('fast'); - $('#show_at_front_container').show('fast'); - $('#product_options').show('fast'); - } else if (parseInt($(this).val()) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE) { - $('#associated_hotel_rooms_tree').show('fast').find('input').each(function() { - $(this).attr('name', $(this).attr('data-name')); - $(this).removeAttr('data-name'); - }); - $('#associated_hotel_tree').show('fast').find('input').each(function() { - $(this).attr('name', $(this).attr('data-name')); - $(this).removeAttr('data-name'); - }); - $('#auto_add_to_cart_container').hide('fast'); - $('#show_at_front_container').show('fast'); - $('#product_options').show('fast'); - } else if (parseInt($(this).val()) == SELLING_PREFERENCE_STANDALONE) { - $('#associated_hotel_rooms_tree').hide('fast').find('input').each(function() { - $(this).attr('data-name', $(this).attr('name')); - $(this).removeAttr('name'); - }); - $('#associated_hotel_tree').hide('fast').find('input').each(function() { - $(this).attr('data-name', $(this).attr('name')); - $(this).removeAttr('name'); - }); - $('#auto_add_to_cart_container').hide('fast'); - $('#show_at_front_container').show('fast'); - $('#product_options').show('fast'); - } + setTimeout(function() { + applySellingPreferenceUIState(); + }, 0); }); $('#selling_preference_type').trigger('change'); $('#simple_product').attr('checked', true); From e5dd7e67a5bc53fb43407074e9cefb394fc6dc45 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Tue, 3 Mar 2026 10:27:45 +0530 Subject: [PATCH 06/34] Fix display service product total and unit price using quantity --- modules/blockcart/blockcart.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/blockcart/blockcart.php b/modules/blockcart/blockcart.php index eb364c6e6..2c2ea59ac 100644 --- a/modules/blockcart/blockcart.php +++ b/modules/blockcart/blockcart.php @@ -358,8 +358,11 @@ class Blockcart extends Module $addedProduct['option_name'] = $productOption->name; } } - $addedProduct['price'] = Tools::displayPrice($addedProduct['unit_price'] * $addedProduct['qty']); - $addedProduct['unit_price'] = Tools::displayPrice($addedProduct['unit_price']); + $quantity = $addedProduct['qty']; + $totalPrice = (float) $addedProduct['unit_price']; + $unitPrice = $totalPrice / $quantity; + $addedProduct['price'] = Tools::displayPrice($totalPrice); + $addedProduct['unit_price'] = Tools::displayPrice($unitPrice); } unset($this->context->cookie->currentAddedProduct); } From 7aaa29e07bec662eea479ca44beb28fcbcbb2bd5 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Tue, 3 Mar 2026 16:20:58 +0530 Subject: [PATCH 07/34] Fix: correct invoice price calculation and fix standalone service product not being added when another product exists --- classes/Cart.php | 35 ++++-- classes/PaymentModule.php | 104 ------------------ classes/order/OrderInvoice.php | 18 +-- controllers/admin/AdminCartsController.php | 2 +- controllers/admin/AdminOrdersController.php | 2 +- controllers/front/CartController.php | 4 +- .../classes/ServiceProductCartDetail.php | 4 +- 7 files changed, 41 insertions(+), 128 deletions(-) diff --git a/classes/Cart.php b/classes/Cart.php index 0b2d86500..4f7d24e46 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -2556,17 +2556,32 @@ class CartCore extends ObjectModel null, (int)$product['id_product'] )) { - if (!isset($standaloneProduct[$id_address])) { - $standaloneProduct[$id_address] = array( - 'product_list' => array(), - 'warehouse_list' => $package['warehouse_list'], - 'carrier_list' => $product['carrier_list'], - 'id_warehouse' => $package['id_warehouse'], - 'id_carrier' => isset($package['id_carrier']) ? $package['id_carrier'] : 0 - ); + $hasStandaloneService = false; + foreach ($selectedServiceProducts as $selectedServiceProduct) { + if ((int) $selectedServiceProduct['id_hotel'] === 0 + && (int) $selectedServiceProduct['id_hotel_cart_booking'] === 0 + ) { + $hasStandaloneService = true; + break; + } + } + + if ($hasStandaloneService) { + if (!isset($standaloneProduct[$id_address])) { + $standaloneProduct[$id_address] = array( + 'product_list' => array(), + 'warehouse_list' => $package['warehouse_list'], + 'carrier_list' => $product['carrier_list'], + 'id_warehouse' => $package['id_warehouse'], + 'id_carrier' => isset($package['id_carrier']) ? $package['id_carrier'] : 0 + ); + } + $productinfo = $product; + $productinfo['id_hotel'] = 0; + $productinfo['id_hotel_cart_booking'] = 0; + $productinfo['id_room_type'] = 0; + $standaloneProduct[$id_address]['product_list'][] = $productinfo; } - $productinfo = $product; - $standaloneProduct[$id_address]['product_list'][] = $product; } } diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 6745a0e2d..4a38a14c7 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -974,110 +974,6 @@ abstract class PaymentModuleCore extends Module $canSellWithHotel = Product::isSellableWithHotel($product['selling_preference_type']); $canSellAsStandalone = Product::isSellableAsStandalone($product['selling_preference_type']); - if ($canSellWithRoomType || $canSellWithHotel || $canSellAsStandalone) { - $idProductRoomType = null; - $idProductHotel = null; - if (isset($product['id_room_type']) && $product['id_room_type']) { - $idProductRoomType = $product['id_room_type']; - } elseif (isset($product['id_hotel']) && $product['id_hotel']) { - $idProductHotel = $product['id_hotel']; - } - - if ($serviceProducts = $objServiceProductCartDetail->getServiceProductsInCart( - $this->context->cart->id, - [], - $idProductHotel, - null, - $idProductRoomType, - $product['id_product'] - )) { - foreach ($serviceProducts as $serviceProduct) { - $isRoomTypeService = !empty($serviceProduct['id_hotel_cart_booking']); - $isHotelService = !$isRoomTypeService && !empty($serviceProduct['id_hotel']); - - if ($isRoomTypeService) { - $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct( - $idProduct, - $order->id, - Product::SELLING_PREFERENCE_WITH_ROOM_TYPE - ); - } elseif ($isHotelService) { - $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct( - $idProduct, - $order->id, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE - ); - } else { - $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct( - $idProduct, - $order->id, - Product::SELLING_PREFERENCE_STANDALONE - ); - } - - if (!$idOrderDetail) { - $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct( - $idProduct, - $order->id, - $product['selling_preference_type'] - ); - } - if (!$idOrderDetail) { - $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct( - $idProduct, - $order->id - ); - } - if (!$idOrderDetail) { - continue; - } - - $objServiceProductOrderDetail = new ServiceProductOrderDetail(); - $objServiceProductOrderDetail->id_product = $idProduct; - $objServiceProductOrderDetail->id_order = $order->id; - $objServiceProductOrderDetail->id_order_detail = $idOrderDetail; - $objServiceProductOrderDetail->id_cart = $this->context->cart->id; - $objServiceProductOrderDetail->unit_price_tax_excl = $serviceProduct['unit_price_tax_excl']; - $objServiceProductOrderDetail->unit_price_tax_incl = $serviceProduct['unit_price_tax_incl']; - $objServiceProductOrderDetail->total_price_tax_excl = $serviceProduct['total_price_tax_excl']; - $objServiceProductOrderDetail->total_price_tax_incl = $serviceProduct['total_price_tax_incl']; - $objServiceProductOrderDetail->name = $product['name']; - $objServiceProductOrderDetail->quantity = $serviceProduct['quantity']; - $objServiceProductOrderDetail->id_product_option = $serviceProduct['id_product_option']; - $objServiceProductOrderDetail->option_name = $serviceProduct['option_name']; - if ($isHotelService) { - $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; - } - } elseif ($isRoomTypeService) { - if (!Validate::isDate($serviceProduct['date_from']) - || !Validate::isDate($serviceProduct['date_to']) - || !(int) $serviceProduct['id_room_type'] - ) { - continue; - } - $roomBookingDetail = $objBookingDetail->getRowByIdOrderIdProductInDateRange( - $order->id, - $serviceProduct['id_room_type'], - $serviceProduct['date_from'], - $serviceProduct['date_to'], - $serviceProduct['id_room'] - ); - if (empty($roomBookingDetail['id'])) { - continue; - } - $objServiceProductOrderDetail->id_htl_booking_detail = $roomBookingDetail['id']; - $objServiceProductOrderDetail->auto_added = $product['auto_add_to_cart']; - } - $objServiceProductOrderDetail->save(); - } - } - continue; - } - if ($canSellWithRoomType && !$canSellWithHotel && !$canSellAsStandalone) { if ($roomTypeServices = $objServiceProductCartDetail->getServiceProductsInCart( $this->context->cart->id, diff --git a/classes/order/OrderInvoice.php b/classes/order/OrderInvoice.php index dc74a2105..911951c59 100644 --- a/classes/order/OrderInvoice.php +++ b/classes/order/OrderInvoice.php @@ -478,14 +478,16 @@ class OrderInvoiceCore extends ObjectModel // - 'total_price_tax_excl' // - 'total_amount' $breakdown = array(); - $order_detail = $this->getProducts(); - $order_detail = array_filter($order_detail, function($v) { - return ( - !$v['is_booking_product'] - && !$v['product_auto_add'] - && Product::isSellableWithRoomType($v['selling_preference_type']) - ); - }); + $order_detail = $this->getProducts( + $order->getProductsDetail( + false, + null, + 0, + Product::PRICE_ADDITION_TYPE_INDEPENDENT, + array(), + Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED + ) + ); $details = $order->getProductTaxesDetails($order_detail, false); if ($sum_composite_taxes) { diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index d7bda66aa..03b07ba0e 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -1670,7 +1670,7 @@ class AdminCartsControllerCore extends AdminController $idServiceProduct, $operator, $quantity, - 0, + false, $idCartBooking ))) { $originalPrice = Product::getPriceStatic($idServiceProduct, false); diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 7be742582..9cafbb2be 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -5644,7 +5644,7 @@ class AdminOrdersControllerCore extends AdminController $idProduct, 'up', $productInformations['product_quantity'], - isset($addressTax->id_hotel) ? $addressTax->id_hotel : 0, + isset($addressTax->id_hotel) ? $addressTax->id_hotel : false, false, isset($productInformations['product_option']) ? $productInformations['product_option'] : null )) { diff --git a/controllers/front/CartController.php b/controllers/front/CartController.php index c22b5f0b5..98fb6eaac 100644 --- a/controllers/front/CartController.php +++ b/controllers/front/CartController.php @@ -665,8 +665,8 @@ class CartControllerCore extends FrontController $this->id_product, $operator, $this->qty, - false, - false, + 0, + 0, isset($idProductOption) ? $idProductOption : null ); if ($operator == 'up') { diff --git a/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php b/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php index 25a1edfcb..8f9a908ec 100644 --- a/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php +++ b/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php @@ -58,10 +58,10 @@ class ServiceProductCartDetail extends ObjectModel if ($idProduct) { $sql .= ' AND `id_product` = '.(int)$idProduct; } - if ($idHotel) { + if ($idHotel !== false && $idHotel !== null) { $sql .= ' AND `id_hotel` = '.(int)$idHotel; } - if ($idHtlCartData) { + if ($idHtlCartData !== false && $idHtlCartData !== null) { $sql .= ' AND `htl_cart_booking_id` = '.(int)$idHtlCartData; } if ($idProductOption) { From 14aa332f3ee81b55deb4a15c1ef93b1280aa0c40 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Tue, 3 Mar 2026 18:50:39 +0530 Subject: [PATCH 08/34] fix: resolve tax breakdown for multi selling-type products --- classes/order/OrderInvoice.php | 68 +++++++++++++++++++++++++--------- 1 file changed, 51 insertions(+), 17 deletions(-) diff --git a/classes/order/OrderInvoice.php b/classes/order/OrderInvoice.php index 911951c59..cc9e95339 100644 --- a/classes/order/OrderInvoice.php +++ b/classes/order/OrderInvoice.php @@ -478,16 +478,32 @@ class OrderInvoiceCore extends ObjectModel // - 'total_price_tax_excl' // - 'total_amount' $breakdown = array(); - $order_detail = $this->getProducts( - $order->getProductsDetail( - false, - null, - 0, - Product::PRICE_ADDITION_TYPE_INDEPENDENT, - array(), - Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED - ) - ); + $order_detail = array(); + $products = $this->getProducts(); + $objServiceProductOrderDetail = new ServiceProductOrderDetail(); + foreach ($products as $product) { + if ($product['is_booking_product'] + || $product['product_auto_add'] + || !Product::isSellableWithRoomType($product['selling_preference_type']) + ) { + continue; + } + + $serviceProductDetail = $objServiceProductOrderDetail->getServiceProductsInOrder( + $product['id_order'], + $product['id_order_detail'] + ); + if (!is_array($serviceProductDetail) || empty($serviceProductDetail)) { + continue; + } + + foreach ($serviceProductDetail as $serviceProduct) { + if (!empty($serviceProduct['id_htl_booking_detail'])) { + $order_detail[] = $product; + break; + } + } + } $details = $order->getProductTaxesDetails($order_detail, false); if ($sum_composite_taxes) { @@ -614,14 +630,32 @@ class OrderInvoiceCore extends ObjectModel // - 'total_price_tax_excl' // - 'total_amount' $breakdown = array(); - $order_detail = $this->getProducts(); - $order_detail = array_filter($order_detail, function($v) { - return ( - !$v['is_booking_product'] - && (Product::isSellableAsStandalone($v['selling_preference_type']) - || Product::isSellableWithHotel($v['selling_preference_type'])) + $order_detail = array(); + $products = $this->getProducts(); + $objServiceProductOrderDetail = new ServiceProductOrderDetail(); + foreach ($products as $product) { + if ($product['is_booking_product'] + || !Product::isSellableAsStandalone($product['selling_preference_type']) + || !Product::isSellableWithHotel($product['selling_preference_type']) + ) { + continue; + } + + $serviceProductDetail = $objServiceProductOrderDetail->getServiceProductsInOrder( + $product['id_order'], + $product['id_order_detail'] ); - }); + if (!is_array($serviceProductDetail) || empty($serviceProductDetail)) { + continue; + } + + foreach ($serviceProductDetail as $serviceProduct) { + if (empty($serviceProduct['id_htl_booking_detail'])) { + $order_detail[] = $product; + break; + } + } + } $details = $order->getProductTaxesDetails($order_detail, false); From 4a644cb4521646d6f68607e896e7e1d1c0ddd9a0 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Tue, 10 Mar 2026 19:18:36 +0530 Subject: [PATCH 09/34] Fixed:Fix incorrect mapping between order detail and service product order detail when product selling type hotel + room type --- .../controllers/orders/helpers/view/view.tpl | 36 +--- classes/Cart.php | 71 +++++--- classes/PaymentModule.php | 165 +++--------------- classes/order/Order.php | 38 +--- classes/order/OrderInvoice.php | 61 ++----- classes/pdf/HTMLTemplateInvoice.php | 106 +---------- .../classes/ServiceProductCartDetail.php | 2 +- .../hotel-reservation-theme/order-detail.tpl | 45 +---- 8 files changed, 108 insertions(+), 416 deletions(-) diff --git a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl index 0053d2631..13e3fcb22 100644 --- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -923,42 +923,18 @@ {* Get total rooms prices *} {assign var=total_rooms_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, true)} {assign var=total_rooms_price_tax_incl value=$order->getTotalProductsWithTaxes(false, true)} - {assign var=all_services_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, false)} - {assign var=all_services_price_tax_incl value=$order->getTotalProductsWithTaxes(false, false)} - {assign var=room_linked_services_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED)} - {assign var=room_linked_services_price_tax_incl value=$order->getTotalProductsWithTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED)} {* Get total extra services including convenience fees prices *} - {assign var=total_products_price_tax_excl value=( - $all_services_price_tax_excl - $room_linked_services_price_tax_excl - )} - {assign var=total_products_price_tax_incl value=( - $all_services_price_tax_incl - $room_linked_services_price_tax_incl - )} + {assign var=total_products_price_tax_excl value=($order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE) + $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE))} + {assign var=total_products_price_tax_incl value=($order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE) + $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE))} {* Get total of extra services and extra demands prices(excluding convenience fee) *} - {assign var=total_room_services_and_demands_tax_excl value=( - $room_linked_services_price_tax_excl - + $totalDemandsPriceTE - )} - {assign var=total_room_services_and_demands_tax_incl value=( - $room_linked_services_price_tax_incl - + $totalDemandsPriceTI - )} + {assign var=total_room_services_and_demands_tax_excl value=($order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) + $totalDemandsPriceTE)} + {assign var=total_room_services_and_demands_tax_incl value=($order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) + $totalDemandsPriceTI)} {* Get total of only convenience fees prices *} - {assign var=total_convenience_fee_tax_excl value=( - $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT) - + $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT) - + $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT) - + $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT) - )} - {assign var=total_convenience_fee_tax_incl value=( - $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT) - + $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT) - + $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT) - + $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT) - )} + {assign var=total_convenience_fee_tax_excl value=$order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT)} + {assign var=total_convenience_fee_tax_incl value=$order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT)} {assign var=order_total_price_tax_excl value=($total_rooms_price_tax_excl + $total_room_services_and_demands_tax_excl + $total_products_price_tax_excl)} {assign var=order_total_price_tax_incl value=($total_rooms_price_tax_incl + $total_room_services_and_demands_tax_incl + $total_products_price_tax_incl)} diff --git a/classes/Cart.php b/classes/Cart.php index 4f7d24e46..ced44ff2d 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -1761,13 +1761,9 @@ class CartCore extends ObjectModel && (!$canSellWithHotel && !$canSellWithRoomType || ($type == Cart::ONLY_STANDALONE_PRODUCTS && !$canSellWithHotel)) ) { - $idHotelCartBooking = null; - $idHotel = null; - if ($type == Cart::ONLY_STANDALONE_PRODUCTS && $canSellWithRoomType) { - // For room+standalone products, standalone totals must exclude room-linked rows. - $idHotelCartBooking = 0; - $idHotel = 0; - } + $idHotelCartBooking = isset($product['id_hotel_cart_booking']) ? (int)$product['id_hotel_cart_booking'] : 0; + $idHotel = isset($product['id_hotel']) ? (int)$product['id_hotel'] : 0; + if ($servicePorducts = $objServiceProductCartDetail->getServiceProductsInCart( $this->id, [], @@ -2522,7 +2518,7 @@ class CartCore extends ObjectModel $product['id_room_type'] = $selectedProduct['id_room_type']; $product['id_hotel_cart_booking'] = $selectedProduct['id_hotel_cart_booking']; $productinfo = $product; - // $productinfo['selling_preference_type'] = Product::SELLING_PREFERENCE_WITH_ROOM_TYPE; + $productinfo['selling_preference_type'] = Product::SELLING_PREFERENCE_WITH_ROOM_TYPE; $orderPackage[$id_address][$selectedProduct['id_hotel']]['product_list'][] = $productinfo; if (!isset($orderPackage[$id_address][$selectedProduct['id_hotel']]['id_hotel'])) { $orderPackage[$id_address][$selectedProduct['id_hotel']]['id_hotel'] = $selectedProduct['id_hotel']; @@ -2556,31 +2552,51 @@ class CartCore extends ObjectModel null, (int)$product['id_product'] )) { - $hasStandaloneService = false; + $array = array(); foreach ($selectedServiceProducts as $selectedServiceProduct) { if ((int) $selectedServiceProduct['id_hotel'] === 0 && (int) $selectedServiceProduct['id_hotel_cart_booking'] === 0 ) { - $hasStandaloneService = true; - break; + if (isset($array[$selectedServiceProduct['id_product']])) { + $array[$selectedServiceProduct['id_product']]['total_price_tax_excl'] += $selectedServiceProduct['total_price_tax_excl']; + $array[$selectedServiceProduct['id_product']]['total_price_tax_incl'] += $selectedServiceProduct['total_price_tax_incl']; + $array[$selectedServiceProduct['id_product']]['quantity'] += $selectedServiceProduct['quantity']; + } else { + $array[$selectedServiceProduct['id_product']] = array( + 'quantity' => $selectedServiceProduct['quantity'], + 'total_price_tax_excl' => $selectedServiceProduct['total_price_tax_excl'], + 'total_price_tax_incl' => $selectedServiceProduct['total_price_tax_incl'], + ); + } + } } - if ($hasStandaloneService) { - if (!isset($standaloneProduct[$id_address])) { - $standaloneProduct[$id_address] = array( - 'product_list' => array(), - 'warehouse_list' => $package['warehouse_list'], - 'carrier_list' => $product['carrier_list'], - 'id_warehouse' => $package['id_warehouse'], - 'id_carrier' => isset($package['id_carrier']) ? $package['id_carrier'] : 0 - ); + if ($array) { + foreach ($array as $standaloneProductData) { + $serviceProduct = $product; + $serviceProduct['cart_quantity'] = $standaloneProductData['quantity']; + $serviceProduct['total'] = $standaloneProductData['total_price_tax_excl']; + $serviceProduct['total_wt'] = $standaloneProductData['total_price_tax_incl']; + $serviceProduct['price'] = $standaloneProductData['total_price_tax_excl'] / $standaloneProductData['quantity']; + $serviceProduct['price_wt'] = $standaloneProductData['total_price_tax_incl'] / $standaloneProductData['quantity']; + $serviceProduct['selling_preference_type'] = Product::SELLING_PREFERENCE_STANDALONE; + $serviceProduct['id_hotel'] = 0; + $serviceProduct['id_hotel_cart_booking'] = 0; + $serviceProduct['id_room_type'] = 0; + if (!isset($standaloneProduct[$id_address])) { + $standaloneProduct[$id_address] = array( + 'product_list' => array(), + 'warehouse_list' => $package['warehouse_list'], + 'carrier_list' => $product['carrier_list'], + 'id_warehouse' => $package['id_warehouse'], + 'id_carrier' => isset($package['id_carrier']) ? $package['id_carrier'] : 0 + ); + } + $productinfo = $serviceProduct; + + $standaloneProduct[$id_address]['product_list'][] = $productinfo; } - $productinfo = $product; - $productinfo['id_hotel'] = 0; - $productinfo['id_hotel_cart_booking'] = 0; - $productinfo['id_room_type'] = 0; - $standaloneProduct[$id_address]['product_list'][] = $productinfo; } } } @@ -2596,6 +2612,9 @@ class CartCore extends ObjectModel )) { $array = array(); foreach($selectedServiceProducts as $hotelProduct) { + if (!isset($hotelProduct['id_hotel']) || !$hotelProduct['id_hotel']) { + continue; + } if (isset($array[$hotelProduct['id_hotel']])) { $array[$hotelProduct['id_hotel']]['total_price_tax_excl'] += $hotelProduct['total_price_tax_excl']; $array[$hotelProduct['id_hotel']]['total_price_tax_incl'] += $hotelProduct['total_price_tax_incl']; @@ -2626,6 +2645,8 @@ class CartCore extends ObjectModel // if (!empty($hotelProducts['products'])) { // foreach($hotelProducts['products'] as $hotelProduct) { $productinfo = $serviceProduct; + $productinfo['selling_preference_type'] = Product::SELLING_PREFERENCE_HOTEL_STANDALONE; + $orderPackage[$id_address][$hotelProduct['id_hotel']]['product_list'][] = $productinfo; if (!isset($orderPackage[$id_address][$hotelProduct['id_hotel']]['id_hotel'])) { $orderPackage[$id_address][$hotelProduct['id_hotel']]['id_hotel'] = $hotelProduct['id_hotel']; diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 4a38a14c7..a022f3484 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -606,16 +606,16 @@ abstract class PaymentModuleCore extends Module $cover_img = $this->context->link->getImageLink($product['link_rewrite'], $this->context->language->iso_code."-default", 'small_default'); } $product_var_tpl['cover_img'] = $cover_img; + $idHotel = isset($product['id_hotel']) ? $product['id_hotel'] : 0; $serviceProducts = $objServiceProductCartDetail->getServiceProductsInCart( $order->id_cart, [], - null, + $idHotel, 0, null, $product['id_product'] ); - $standaloneServiceProducts = array(); - $hotelServiceProducts = array(); + foreach ($serviceProducts as $serviceProduct) { $orderServiceProducts[] = array_merge($product_var_tpl, $serviceProduct); } @@ -1061,9 +1061,9 @@ abstract class PaymentModuleCore extends Module } elseif ($canSellAsStandalone && !$canSellWithRoomType && !$canSellWithHotel) { if ($standaloneProducts = $objServiceProductCartDetail->getServiceProductsInCart( $this->context->cart->id, - [Product::SELLING_PREFERENCE_STANDALONE], - null, - null, + [], + 0, + 0, null, $product['id_product'] )) { @@ -1089,108 +1089,7 @@ abstract class PaymentModuleCore extends Module $objServiceProductOrderDetail->save(); } } - } elseif ($canSellWithRoomType || $canSellWithHotel || $canSellAsStandalone) { - $idProductRoomType = null; - $idProductHotel = null; - if (isset($product['id_room_type']) && $product['id_room_type']) { - $idProductRoomType = $product['id_room_type']; - } elseif (isset($product['id_hotel']) && $product['id_hotel']) { - $idProductHotel = $product['id_hotel']; - } - - if ($serviceProducts = $objServiceProductCartDetail->getServiceProductsInCart( - $this->context->cart->id, - [], - $idProductHotel, - null, - $idProductRoomType, - $product['id_product'] - )) { - foreach ($serviceProducts as $serviceProduct) { - $isRoomTypeService = !empty($serviceProduct['id_hotel_cart_booking']); - $isHotelService = !$isRoomTypeService && !empty($serviceProduct['id_hotel']); - - if ($isRoomTypeService) { - $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct( - $idProduct, - $order->id, - Product::SELLING_PREFERENCE_WITH_ROOM_TYPE - ); - } elseif ($isHotelService) { - $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct( - $idProduct, - $order->id, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE - ); - } else { - $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct( - $idProduct, - $order->id, - Product::SELLING_PREFERENCE_STANDALONE - ); - } - - if (!$idOrderDetail) { - $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct( - $idProduct, - $order->id, - $product['selling_preference_type'] - ); - } - if (!$idOrderDetail) { - $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct( - $idProduct, - $order->id - ); - } - if (!$idOrderDetail) { - continue; - } - - $objServiceProductOrderDetail = new ServiceProductOrderDetail(); - $objServiceProductOrderDetail->id_product = $idProduct; - $objServiceProductOrderDetail->id_order = $order->id; - $objServiceProductOrderDetail->id_order_detail = $idOrderDetail; - $objServiceProductOrderDetail->id_cart = $this->context->cart->id; - $objServiceProductOrderDetail->unit_price_tax_excl = $serviceProduct['unit_price_tax_excl']; - $objServiceProductOrderDetail->unit_price_tax_incl = $serviceProduct['unit_price_tax_incl']; - $objServiceProductOrderDetail->total_price_tax_excl = $serviceProduct['total_price_tax_excl']; - $objServiceProductOrderDetail->total_price_tax_incl = $serviceProduct['total_price_tax_incl']; - $objServiceProductOrderDetail->name = $product['name']; - $objServiceProductOrderDetail->quantity = $serviceProduct['quantity']; - $objServiceProductOrderDetail->id_product_option = $serviceProduct['id_product_option']; - $objServiceProductOrderDetail->option_name = $serviceProduct['option_name']; - if ($isHotelService) { - $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; - } - } elseif ($isRoomTypeService) { - if (!Validate::isDate($serviceProduct['date_from']) - || !Validate::isDate($serviceProduct['date_to']) - || !(int) $serviceProduct['id_room_type'] - ) { - continue; - } - $roomBookingDetail = $objBookingDetail->getRowByIdOrderIdProductInDateRange( - $order->id, - $serviceProduct['id_room_type'], - $serviceProduct['date_from'], - $serviceProduct['date_to'], - $serviceProduct['id_room'] - ); - if (empty($roomBookingDetail['id'])) { - continue; - } - $objServiceProductOrderDetail->id_htl_booking_detail = $roomBookingDetail['id']; - $objServiceProductOrderDetail->auto_added = $product['auto_add_to_cart']; - } - $objServiceProductOrderDetail->save(); - } - } - } + } } } @@ -1300,50 +1199,28 @@ abstract class PaymentModuleCore extends Module $normal_products_data_txt = $this->getEmailTemplateContent('service_product_data_text.tpl', Mail::TYPE_TEXT, $orderServiceProducts); // get order total information html/txt files - // room-related selling types: - // 1: with room type, 3: hotel+room, 6: standalone+room, 7: hotel+room+standalone - $roomRelatedSellingTypes = array( - Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, - ); - // total room price - $room_auto_with_room_tax_excl = 0; - $room_auto_with_room_tax_incl = 0; - foreach ($roomRelatedSellingTypes as $sellingType) { - $room_auto_with_room_tax_excl += $order->getTotalProductsWithoutTaxes(false, false, $sellingType, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM); - $room_auto_with_room_tax_incl += $order->getTotalProductsWithTaxes(false, false, $sellingType, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM); - } - $room_price_tax_excl = $order->getTotalProductsWithoutTaxes(false, true) + $room_auto_with_room_tax_excl; - $room_price_tax_incl = $order->getTotalProductsWithTaxes(false, true) + $room_auto_with_room_tax_incl; + $room_price_tax_excl = $order->getTotalProductsWithoutTaxes(false, true) + $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM); + $room_price_tax_incl = $order->getTotalProductsWithTaxes(false, true) + $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM); $room_tax = ($room_price_tax_incl - $room_price_tax_excl); // extra services - $additional_service_price_tax_excl = (float) $cart_booking_data['total_extra_demands_te']; - $additional_service_price_tax_incl = (float) $cart_booking_data['total_extra_demands_ti']; - $additional_service_price_tax_excl += $order->getTotalProductsWithoutTaxes(false, false, null, 0, Product::PRICE_ADDITION_TYPE_INDEPENDENT, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED); - $additional_service_price_tax_incl += $order->getTotalProductsWithTaxes(false, false, null, 0, Product::PRICE_ADDITION_TYPE_INDEPENDENT,null,Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED); + $additional_service_price_tax_excl = ($order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 0) + $cart_booking_data['total_extra_demands_te']); + $additional_service_price_tax_incl = ($order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 0) + $cart_booking_data['total_extra_demands_ti']); $additional_service_tax = ($additional_service_price_tax_incl - $additional_service_price_tax_excl); // convenience fee price - $total_convenience_fee_ti = 0; - $total_convenience_fee_te = 0; - foreach ($roomRelatedSellingTypes as $sellingType) { - $total_convenience_fee_ti += $order->getTotalProductsWithTaxes(false, false, $sellingType, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT); - $total_convenience_fee_te += $order->getTotalProductsWithoutTaxes(false, false, $sellingType, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT); - } + $total_convenience_fee_ti = $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT); + $total_convenience_fee_te = $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT); $total_convenience_fee_tax = $total_convenience_fee_ti - $total_convenience_fee_te; // service products - $all_services_price_tax_incl = $order->getTotalProductsWithTaxes(false, false); - $all_services_price_tax_excl = $order->getTotalProductsWithoutTaxes(false, false); - $room_linked_services_price_tax_incl = $order->getTotalProductsWithTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED); - $room_linked_services_price_tax_excl = $order->getTotalProductsWithoutTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED); - $total_standard_products_tax_incl = $all_services_price_tax_incl - $room_linked_services_price_tax_incl; - $total_standard_products_tax_excl = $all_services_price_tax_excl - $room_linked_services_price_tax_excl; - $service_products_tax = $total_standard_products_tax_incl - $total_standard_products_tax_excl; + $standalone_products_price_tax_excl = $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE); + $standalone_products_price_tax_incl = $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE); + $hotel_standalone_products_price_tax_excl = $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE); + $hotel_standalone_products_price_tax_incl = $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE); + + $service_products_tax = ($standalone_products_price_tax_incl + $hotel_standalone_products_price_tax_incl) - ($standalone_products_price_tax_excl + $hotel_standalone_products_price_tax_excl); $total_order_tax = $room_tax + $additional_service_tax + $total_convenience_fee_tax + $service_products_tax; @@ -1360,12 +1237,12 @@ abstract class PaymentModuleCore extends Module 'total_convenience_fee_te' => Tools::displayPrice($total_convenience_fee_te, $this->context->currency, false), 'total_convenience_fee_tax' => Tools::displayPrice($total_convenience_fee_tax, $this->context->currency, false), 'service_products_price_tax_excl' => Tools::displayPrice( - $total_standard_products_tax_excl, + ($standalone_products_price_tax_excl + $hotel_standalone_products_price_tax_excl), $this->context->currency, false ), 'service_products_price_tax_incl' => Tools::displayPrice( - $total_standard_products_tax_incl, + ($standalone_products_price_tax_incl + $hotel_standalone_products_price_tax_incl), $this->context->currency, false ), diff --git a/classes/order/Order.php b/classes/order/Order.php index ca9ef9327..0ed9581a3 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -617,8 +617,7 @@ class OrderCore extends ObjectModel $selling_preference_type = null, $product_auto_add = null, $product_price_addition_type = null, - $ids_order_detail = [], - $service_product_context = null + $ids_order_detail = [] ) { $sql = 'SELECT *, od.`selling_preference_type` as selling_preference_type FROM `'._DB_PREFIX_.'order_detail` od @@ -635,37 +634,12 @@ class OrderCore extends ObjectModel if (!$is_booking && $selling_preference_type !== null) { $sql .= ' AND od.`selling_preference_type` = '. (int)$selling_preference_type; } - if (!$is_booking && $product_auto_add !== null) { + if (!$is_booking && $selling_preference_type == Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $product_auto_add !== null) { $sql .= ' AND od.`product_auto_add` = '. (int)$product_auto_add; } - if (!$is_booking && $product_auto_add == 1 && $product_price_addition_type !== null) { + if (!$is_booking && $selling_preference_type == Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $product_auto_add == 1 && $product_price_addition_type !== null) { $sql .= ' AND od.`product_price_addition_type` = '. (int)$product_price_addition_type; } - - if (!$is_booking && $service_product_context !== null) { - if ((int) $service_product_context === self::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED) { - - $sql .= ' - AND EXISTS ( - SELECT 1 - FROM ' . _DB_PREFIX_ . 'service_product_order_detail spod - WHERE spod.id_order = od.id_order - AND spod.id_order_detail = od.id_order_detail - AND spod.id_htl_booking_detail > 0 - )'; - - } elseif ((int) $service_product_context === self::SERVICE_PRODUCT_CONTEXT_NON_ROOM) { - - $sql .= ' - AND EXISTS ( - SELECT 1 - FROM ' . _DB_PREFIX_ . 'service_product_order_detail spod - WHERE spod.id_order = od.id_order - AND spod.id_order_detail = od.id_order_detail - AND spod.id_htl_booking_detail = 0 - )'; - } - } } return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); } @@ -1154,11 +1128,10 @@ class OrderCore extends ObjectModel $product_auto_add = null, $product_price_addition_type = null, $ids_order_detail = [], - $service_product_context = null ) { // update if (!$products) { - $products = $this->getProductsDetail($bookingProducts, $selling_preference_type, $product_auto_add, $product_price_addition_type, $ids_order_detail, $service_product_context); + $products = $this->getProductsDetail($bookingProducts, $selling_preference_type, $product_auto_add, $product_price_addition_type, $ids_order_detail); } $return = 0; @@ -1181,11 +1154,10 @@ class OrderCore extends ObjectModel $product_auto_add = null, $product_price_addition_type = null, $ids_order_detail = [], - $service_product_context = null ) { /* Retro-compatibility (now set directly on the validateOrder() method) */ if (!$products) { - $products = $this->getProductsDetail($bookingProducts, $selling_preference_type, $product_auto_add, $product_price_addition_type, $ids_order_detail, $service_product_context); + $products = $this->getProductsDetail($bookingProducts, $selling_preference_type, $product_auto_add, $product_price_addition_type, $ids_order_detail); } $return = 0; diff --git a/classes/order/OrderInvoice.php b/classes/order/OrderInvoice.php index cc9e95339..f97c589fc 100644 --- a/classes/order/OrderInvoice.php +++ b/classes/order/OrderInvoice.php @@ -478,32 +478,11 @@ class OrderInvoiceCore extends ObjectModel // - 'total_price_tax_excl' // - 'total_amount' $breakdown = array(); - $order_detail = array(); - $products = $this->getProducts(); - $objServiceProductOrderDetail = new ServiceProductOrderDetail(); - foreach ($products as $product) { - if ($product['is_booking_product'] - || $product['product_auto_add'] - || !Product::isSellableWithRoomType($product['selling_preference_type']) - ) { - continue; - } + $order_detail = $this->getProducts(); + $order_detail = array_filter($order_detail, function($v) { + return (!$v['is_booking_product'] && !$v['product_auto_add'] && Product::isSellableWithRoomType($v['selling_preference_type'])); + }); - $serviceProductDetail = $objServiceProductOrderDetail->getServiceProductsInOrder( - $product['id_order'], - $product['id_order_detail'] - ); - if (!is_array($serviceProductDetail) || empty($serviceProductDetail)) { - continue; - } - - foreach ($serviceProductDetail as $serviceProduct) { - if (!empty($serviceProduct['id_htl_booking_detail'])) { - $order_detail[] = $product; - break; - } - } - } $details = $order->getProductTaxesDetails($order_detail, false); if ($sum_composite_taxes) { @@ -632,30 +611,14 @@ class OrderInvoiceCore extends ObjectModel $breakdown = array(); $order_detail = array(); $products = $this->getProducts(); - $objServiceProductOrderDetail = new ServiceProductOrderDetail(); - foreach ($products as $product) { - if ($product['is_booking_product'] - || !Product::isSellableAsStandalone($product['selling_preference_type']) - || !Product::isSellableWithHotel($product['selling_preference_type']) - ) { - continue; - } - - $serviceProductDetail = $objServiceProductOrderDetail->getServiceProductsInOrder( - $product['id_order'], - $product['id_order_detail'] - ); - if (!is_array($serviceProductDetail) || empty($serviceProductDetail)) { - continue; - } - - foreach ($serviceProductDetail as $serviceProduct) { - if (empty($serviceProduct['id_htl_booking_detail'])) { - $order_detail[] = $product; - break; - } - } - } + $order_detail = $this->getProducts(); + $order_detail = array_filter($order_detail, function($v) { + return (!$v['is_booking_product'] && ( + Product::isSellableAsStandalone($v['selling_preference_type']) + || Product::isSellableWithHotel($v['selling_preference_type']) + )); + }); + $details = $order->getProductTaxesDetails($order_detail, false); diff --git a/classes/pdf/HTMLTemplateInvoice.php b/classes/pdf/HTMLTemplateInvoice.php index 23839e4e8..37b895353 100644 --- a/classes/pdf/HTMLTemplateInvoice.php +++ b/classes/pdf/HTMLTemplateInvoice.php @@ -660,104 +660,14 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate $footer['service_products_price_tax_excl'] = 0; $footer['service_products_price_tax_incl'] = 0; if ($idsOrderDetail = array_column($order_details, 'id_order_detail')) { - $roomTypeSellingPreferenceTypes = array( - Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, - ); - $serviceSellingPreferenceTypes = array( - Product::SELLING_PREFERENCE_HOTEL_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, - ); - - $footer['room_price_tax_excl'] = $this->order->getTotalProductsWithoutTaxes(false, true, null, null, null, $idsOrderDetail); - $footer['room_price_tax_incl'] = $this->order->getTotalProductsWithTaxes(false, true, null, null, null, $idsOrderDetail); - - foreach ($roomTypeSellingPreferenceTypes as $sellingPreferenceType) { - $footer['room_price_tax_excl'] += $this->order->getTotalProductsWithoutTaxes( - false, - false, - $sellingPreferenceType, - 1, - Product::PRICE_ADDITION_TYPE_WITH_ROOM, - $idsOrderDetail, - Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED - ); - $footer['room_price_tax_incl'] += $this->order->getTotalProductsWithTaxes( - false, - false, - $sellingPreferenceType, - 1, - Product::PRICE_ADDITION_TYPE_WITH_ROOM, - $idsOrderDetail, - Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED - ); - $footer['additional_service_price_tax_excl'] += $this->order->getTotalProductsWithoutTaxes( - false, - false, - $sellingPreferenceType, - 0, - null, - $idsOrderDetail, - Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED - ); - $footer['additional_service_price_tax_incl'] += $this->order->getTotalProductsWithTaxes( - false, - false, - $sellingPreferenceType, - 0, - null, - $idsOrderDetail, - Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED - ); - $footer['total_convenience_fee_te'] += $this->order->getTotalProductsWithoutTaxes( - false, - false, - $sellingPreferenceType, - 1, - Product::PRICE_ADDITION_TYPE_INDEPENDENT, - $idsOrderDetail, - Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED - ); - $footer['total_convenience_fee_ti'] += $this->order->getTotalProductsWithTaxes( - false, - false, - $sellingPreferenceType, - 1, - Product::PRICE_ADDITION_TYPE_INDEPENDENT, - $idsOrderDetail, - Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED - ); - } - - foreach ($serviceSellingPreferenceTypes as $sellingPreferenceType) { - $footer['service_products_price_tax_excl'] += $this->order->getTotalProductsWithoutTaxes( - false, - false, - $sellingPreferenceType, - false, - false, - $idsOrderDetail, - Order::SERVICE_PRODUCT_CONTEXT_NON_ROOM - ); - $footer['service_products_price_tax_incl'] += $this->order->getTotalProductsWithTaxes( - false, - false, - $sellingPreferenceType, - false, - false, - $idsOrderDetail, - Order::SERVICE_PRODUCT_CONTEXT_NON_ROOM - ); - } - - $footer['additional_service_price_tax_excl'] += $totalDemandsPriceTE; - $footer['additional_service_price_tax_incl'] += $totalDemandsPriceTI; + $footer['room_price_tax_excl'] = $this->order->getTotalProductsWithoutTaxes(false, true, null, null, null, $idsOrderDetail) + $this->order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM, $idsOrderDetail); + $footer['room_price_tax_incl'] = $this->order->getTotalProductsWithTaxes(false, true, null, null, null, $idsOrderDetail) + $this->order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM, $idsOrderDetail); + $footer['service_products_price_tax_excl'] = $this->order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE, false, false, $idsOrderDetail) + $this->order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE, false, false, $idsOrderDetail); + $footer['service_products_price_tax_incl'] = $this->order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE, false, false, $idsOrderDetail) + $this->order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE, false, false, $idsOrderDetail); + $footer['additional_service_price_tax_excl'] = $this->order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 0, null, $idsOrderDetail) + $totalDemandsPriceTE; + $footer['additional_service_price_tax_incl'] = $this->order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 0, null, $idsOrderDetail) + $totalDemandsPriceTI; + $footer['total_convenience_fee_te'] = $this->order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT, $idsOrderDetail); + $footer['total_convenience_fee_ti'] = $this->order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT, $idsOrderDetail); } $footer['total_paid_real'] = $this->order_invoice->getTotalPaid(); diff --git a/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php b/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php index 8f9a908ec..cbb03bf63 100644 --- a/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php +++ b/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php @@ -348,7 +348,7 @@ class ServiceProductCartDetail extends ObjectModel $productInfo['id_room'] = 0; } - if ($detailedInfo) { + if ($detailedInfo && $product['id_hotel']) { $objHotelBranchInformation = new HotelBranchInformation(); $hotelInfo = $objHotelBranchInformation->hotelBranchesInfo($language->id, 2, 1, $product['id_hotel']); $hotelInfo['location'] = $hotelInfo['hotel_name'].', '.$hotelInfo['city']. diff --git a/themes/hotel-reservation-theme/order-detail.tpl b/themes/hotel-reservation-theme/order-detail.tpl index 81fa7f340..d1682db6a 100644 --- a/themes/hotel-reservation-theme/order-detail.tpl +++ b/themes/hotel-reservation-theme/order-detail.tpl @@ -317,27 +317,14 @@ {assign var=room_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, true)} {assign var=room_price_tax_incl value=$order->getTotalProductsWithTaxes(false, true)} - {assign var=room_services_price_tax_excl value=( - $order->getTotalProductsWithoutTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED) - + $total_demands_price_te - )} - {assign var=room_services_price_tax_incl value=( - $order->getTotalProductsWithTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED) - + $total_demands_price_ti - )} - {assign var=all_services_price_tax_incl value=$order->getTotalProductsWithTaxes(false, false)} - {assign var=all_services_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, false)} - {assign var=room_linked_services_price_tax_incl value=$order->getTotalProductsWithTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED)} - {assign var=room_linked_services_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED)} + + {assign var=room_services_price_tax_excl value=($order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) + $total_demands_price_te)} + {assign var=room_services_price_tax_incl value=($order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) + $total_demands_price_ti)} {assign var=total_tax_without_discount value=(($room_price_tax_incl - $room_price_tax_excl) + ($room_services_price_tax_incl - $room_services_price_tax_excl ))} - {assign var=total_standard_products_tax_incl value=( - $all_services_price_tax_incl - $room_linked_services_price_tax_incl - )} - {assign var=total_standard_products_tax_excl value=( - $all_services_price_tax_excl - $room_linked_services_price_tax_excl - )} + {assign var=total_standard_products_tax_incl value=($order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE) + $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE))} + {assign var=total_standard_products_tax_excl value=($order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE) + $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE))} {if isset($cart_htl_data) && $cart_htl_data} @@ -739,25 +726,11 @@ {assign var=room_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, true)} {assign var=room_price_tax_incl value=$order->getTotalProductsWithTaxes(false, true)} - {assign var=room_services_price_tax_excl value=( - $order->getTotalProductsWithoutTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED) - + $total_demands_price_te - )} - {assign var=room_services_price_tax_incl value=( - $order->getTotalProductsWithTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED) - + $total_demands_price_ti - )} - {assign var=all_services_price_tax_incl value=$order->getTotalProductsWithTaxes(false, false)} - {assign var=all_services_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, false)} - {assign var=room_linked_services_price_tax_incl value=$order->getTotalProductsWithTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED)} - {assign var=room_linked_services_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED)} + {assign var=room_services_price_tax_excl value=($order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) + $total_demands_price_te)} + {assign var=room_services_price_tax_incl value=($order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) + $total_demands_price_ti)} - {assign var=total_standard_products_tax_incl value=( - $all_services_price_tax_incl - $room_linked_services_price_tax_incl - )} - {assign var=total_standard_products_tax_excl value=( - $all_services_price_tax_excl - $room_linked_services_price_tax_excl - )} + {assign var=total_standard_products_tax_incl value=($order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE) + $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE))} + {assign var=total_standard_products_tax_excl value=($order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE) + $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE))} {assign var=total_tax_without_discount value=(($room_price_tax_incl - $room_price_tax_excl) + ($room_services_price_tax_incl - $room_services_price_tax_excl) + ($total_standard_products_tax_incl - $total_standard_products_tax_excl))} From b3240226005394f832a2073ca0ab8a2bb31519e4 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Mon, 25 May 2026 14:33:49 +0530 Subject: [PATCH 10/34] Fixed: Service product prices are incorrect when added to an order created in a different currency. --- .../normal_products/informations.tpl | 41 ++- .../controllers/normal_products/prices.tpl | 46 ++- .../normal_products/selected_option.tpl | 98 ++++++ .../orders/_cart_booking_demands.tpl | 2 +- .../_add_order_extra_services_tab_content.tpl | 32 +- ..._extra_services_facilities_tab_content.tpl | 6 +- ..._services_service_products_tab_content.tpl | 36 ++- classes/Cart.php | 216 ++++++------- classes/PaymentModule.php | 42 +-- classes/Product.php | 24 +- classes/order/Order.php | 25 +- classes/order/OrderDetail.php | 22 +- classes/order/OrderInvoice.php | 6 +- .../WebserviceSpecificManagementBookings.php | 21 +- controllers/admin/AdminCartsController.php | 126 ++++++-- .../admin/AdminNormalProductsController.php | 51 +-- controllers/admin/AdminOrdersController.php | 293 +++++++++++------- controllers/admin/AdminProductsController.php | 18 +- controllers/admin/AdminStatsController.php | 4 +- controllers/front/CartController.php | 52 +++- controllers/front/GuestTrackingController.php | 33 +- .../front/OrderConfirmationController.php | 93 +++--- controllers/front/OrderDetailController.php | 87 ++---- js/admin.js | 12 + js/admin/normal_products.js | 39 +-- modules/blockcart/ajax-cart.js | 20 +- .../classes/HotelCartBookingData.php | 19 ++ .../classes/HotelHelper.php | 2 +- .../classes/RoomTypeServiceProduct.php | 7 +- .../classes/ServiceProductCartDetail.php | 24 +- .../helpers/view/view.tpl | 2 +- .../qlostatsserviceproducts.php | 25 +- .../_partials/cart_booking_demands.tpl | 4 +- .../_partials/service-products-list-row.tpl | 2 +- .../js/modules/blockcart/ajax-cart.js | 22 +- .../modules/blockcart/blockcart.tpl | 6 +- .../order-confirmation.tpl | 16 +- .../hotel-reservation-theme/order-detail.tpl | 2 +- themes/hotel-reservation-theme/product.tpl | 2 +- 39 files changed, 940 insertions(+), 638 deletions(-) create mode 100644 admin/themes/default/template/controllers/normal_products/selected_option.tpl diff --git a/admin/themes/default/template/controllers/normal_products/informations.tpl b/admin/themes/default/template/controllers/normal_products/informations.tpl index 3bf54bd1b..b1d0b9f72 100644 --- a/admin/themes/default/template/controllers/normal_products/informations.tpl +++ b/admin/themes/default/template/controllers/normal_products/informations.tpl @@ -231,21 +231,34 @@ {* Code For Standard product working *}
-
diff --git a/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl b/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl index 3dc6241f0..d56daffe8 100644 --- a/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl +++ b/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl @@ -96,7 +96,7 @@ $selectedRoomServiceProduct['date_from'], $selectedRoomServiceProduct['date_to'] ) > 1} - {l s='/ night'} + {l s='/ day'} {/if} {/if} @@ -134,16 +134,26 @@
- - + + +
+ +
+
+ +
+
+ +
diff --git a/admin/themes/default/template/controllers/orders/modals/_extra_services_facilities_tab_content.tpl b/admin/themes/default/template/controllers/orders/modals/_extra_services_facilities_tab_content.tpl index 3537d8dd2..e4f40435a 100644 --- a/admin/themes/default/template/controllers/orders/modals/_extra_services_facilities_tab_content.tpl +++ b/admin/themes/default/template/controllers/orders/modals/_extra_services_facilities_tab_content.tpl @@ -51,7 +51,7 @@ {$currencySign} {if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY} - {l s='/ night'} + {l s='/ day'} {/if}
@@ -122,7 +122,7 @@ {/if} {if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY} - {l s='/ night'} + {l s='/ day'} {/if}
@@ -159,7 +159,7 @@ diff --git a/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl b/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl index 4f6ce1c58..d8d3ef96d 100644 --- a/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl +++ b/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl @@ -87,7 +87,7 @@ $additionalServices['date_from'], $additionalServices['date_to'] ) > 1} - {l s='/ night'} + {l s='/ day'} {/if} @@ -161,7 +161,7 @@ $additionalServices['date_from'], $additionalServices['date_to'] ) > 1} - {l s='/ night'} + {l s='/ day'} {/if} @@ -197,16 +197,26 @@
- - + + +
+ +
+
+ +
+
+ +
@@ -304,7 +314,7 @@ $additionalServices['date_from'], $additionalServices['date_to'] ) > 1} - {l s='/ night'} + {l s='/ day'} {/if}
- + diff --git a/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl b/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl index da29873a8..bb77c1095 100644 --- a/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl +++ b/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl @@ -99,7 +99,7 @@ $selectedRoomServiceProduct['date_from'], $selectedRoomServiceProduct['date_to'] ) > 1} - {l s='/ day'} + {l s='/ night'} {/if} {/if} diff --git a/admin/themes/default/template/controllers/orders/modals/_extra_services_facilities_tab_content.tpl b/admin/themes/default/template/controllers/orders/modals/_extra_services_facilities_tab_content.tpl index e4f40435a..3537d8dd2 100644 --- a/admin/themes/default/template/controllers/orders/modals/_extra_services_facilities_tab_content.tpl +++ b/admin/themes/default/template/controllers/orders/modals/_extra_services_facilities_tab_content.tpl @@ -51,7 +51,7 @@ {$currencySign} {if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY} - {l s='/ day'} + {l s='/ night'} {/if} @@ -122,7 +122,7 @@ {/if} {if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY} - {l s='/ day'} + {l s='/ night'} {/if} @@ -159,7 +159,7 @@ diff --git a/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl b/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl index b322c7dde..de2af862f 100644 --- a/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl +++ b/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl @@ -89,7 +89,7 @@ $additionalServices['date_from'], $additionalServices['date_to'] ) > 1} - {l s='/ day'} + {l s='/ night'} {/if} @@ -164,7 +164,7 @@ $additionalServices['date_from'], $additionalServices['date_to'] ) > 1} - {l s='/ day'} + {l s='/ night'} {/if} @@ -320,7 +320,7 @@ $additionalServices['date_from'], $additionalServices['date_to'] ) > 1} - {l s='/ day'} + {l s='/ night'} {/if} @@ -729,8 +729,8 @@ {assign var=room_services_price_tax_excl value=($order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) + $total_demands_price_te)} {assign var=room_services_price_tax_incl value=($order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) + $total_demands_price_ti)} - {assign var=total_standard_products_tax_incl value=($order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE) + $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE))} - {assign var=total_standard_products_tax_excl value=($order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE) + $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE))} + {assign var=total_standard_products_tax_incl value=($order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_STANDALONE) + $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_HOTEL))} + {assign var=total_standard_products_tax_excl value=($order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_STANDALONE) + $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_HOTEL))} {assign var=total_tax_without_discount value=(($room_price_tax_incl - $room_price_tax_excl) + ($room_services_price_tax_incl - $room_services_price_tax_excl) + ($total_standard_products_tax_incl - $total_standard_products_tax_excl))} @@ -979,7 +979,7 @@ ({$hotel_booking_detail.adults|string_format:'%02d'} {if $hotel_booking_detail.adults > 1}{l s='Adults'}{else}{l s='Adult'}{/if}{if $hotel_booking_detail.children > 0}{l s=', '}{$hotel_booking_detail.children|string_format:'%02d'} {if $hotel_booking_detail.children > 1}{l s='Children'}{else}{l s='Child'}{/if}{/if}) - {if $hotel_booking_detail.is_cancelled}{l s='Cancelled'}{else if $hotel_booking_detail.is_refunded}{l s='Refunded'}{else if $hotel_booking_detail.refund_denied}{l s='Refund denied'}{else if $hotel_booking_detail.id_status != $ROOM_STATUS_ALLOTED}{if $hotel_booking_detail.id_status == $ROOM_STATUS_CHECKED_OUT}{l s='Checked-Out'}{else}{l s='Checked-In'}{/if}{/if} + {if $hotel_booking_detail.is_cancelled}{l s='Cancelled'}{else if $hotel_booking_detail.is_refunded}{l s='Refunded'}{else if $hotel_booking_detail.refund_denied}{l s='Refund denied'} {include file='_partials/htl-tooltip.tpl' tooltip_content={l s='Refund for this booking is denied. Please contact admin for more detail.'}}{else if $hotel_booking_detail.id_status != $ROOM_STATUS_ALLOTED}{if $hotel_booking_detail.id_status == $ROOM_STATUS_CHECKED_OUT}{l s='Checked-Out'}{else}{l s='Checked-In'}{/if}{/if} @@ -1037,7 +1037,7 @@ {$product_option.name}{if isset($product_option.option_name) && $product_option.option_name} : {$product_option.option_name}{/if} - {if $product_option.is_cancelled}{l s='Cancelled'}{else if $product_option.is_refunded}{l s='Refunded'}{else if isset($product_option.refund_denied) && $product_option.refund_denied}{l s='Refund denied'}{/if} + {if $product_option.is_cancelled}{l s='Cancelled'}{else if $product_option.is_refunded}{l s='Refunded'}{else if isset($product_option.refund_denied) && $product_option.refund_denied}{l s='Refund denied'} {include file='_partials/htl-tooltip.tpl' tooltip_content={l s='Refund for this product is denied. Please contact admin for more detail.'}}{/if} {if $product_option.allow_multiple_quantity}
diff --git a/themes/hotel-reservation-theme/shopping-cart-detail.tpl b/themes/hotel-reservation-theme/shopping-cart-detail.tpl index ccbb199e7..668006b40 100644 --- a/themes/hotel-reservation-theme/shopping-cart-detail.tpl +++ b/themes/hotel-reservation-theme/shopping-cart-detail.tpl @@ -120,22 +120,18 @@
-

- - {displayPrice price=($rm_v['amount'])} - +

+ {displayPrice price=($rm_v['amount'])} {if (($rm_v['amount'] - $rm_v['amount_without_auto_add']) > 0) && (in_array($data_v['id_product'], $discounted_products) || $PS_ROOM_PRICE_AUTO_ADD_BREAKDOWN)} - - - -

{l s='Total rooms price'} {if $display_tax_label}{if $priceDisplay} {l s='(Excl.'} {else}{l s='(Incl.)'}{/if} {l s='all taxes.)'}{/if}

From b4a087be55f998bc38a685d83a43d5822b114bb9 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Mon, 1 Jun 2026 11:35:05 +0530 Subject: [PATCH 17/34] Fix price calculation issue labal --- .../_partials/cart_booking_demands.tpl | 4 ++-- .../_partials/service-products-list-row.tpl | 2 +- themes/hotel-reservation-theme/product.tpl | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl index a7c56b4b1..fe620e385 100644 --- a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl +++ b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl @@ -82,7 +82,7 @@

- {if isset($selected_adv_option) && isset($demand['adv_option'][$selected_adv_option]['price'])}{convertPrice price = $demand['adv_option'][$selected_adv_option]['price']|escape:'html':'UTF-8'}{else}{convertPrice price = $demand['price']|escape:'html':'UTF-8'}{/if}{if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY}{l s='/Day'}{/if} + {if isset($selected_adv_option) && isset($demand['adv_option'][$selected_adv_option]['price'])}{convertPrice price = $demand['adv_option'][$selected_adv_option]['price']|escape:'html':'UTF-8'}{else}{convertPrice price = $demand['price']|escape:'html':'UTF-8'}{/if}{if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY}{l s='/Night'}{/if}

@@ -183,7 +183,7 @@ $product.price_calculation_method, $cartRoom.date_from|default:'', $cartRoom.date_to|default:'' - ) > 1}{l s='/Day'}{/if} + ) > 1}{l s='/Night'}{/if} {/if} diff --git a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl index 8aba19cd4..ea97398e2 100644 --- a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl +++ b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl @@ -86,7 +86,7 @@ $service_product.date_from|default:$date_from|default:'', $service_product.date_to|default:$date_to|default:'' ) > 1} - {l s='/Day'} + {l s='/Night'} {/if} {/block} {if $service_product.allow_multiple_quantity && $service_product.available_for_order && $service_product.max_quantity > 0} diff --git a/themes/hotel-reservation-theme/product.tpl b/themes/hotel-reservation-theme/product.tpl index c6f23c5e2..f9836c246 100644 --- a/themes/hotel-reservation-theme/product.tpl +++ b/themes/hotel-reservation-theme/product.tpl @@ -455,7 +455,7 @@
{/if}
-

{$demand['name']|escape:'html':'UTF-8'} {if $product->show_price && !isset($restricted_country_mode) && !$PS_CATALOG_MODE}{convertPrice price = $demand['price']}{if $demand['price_calc_method'] == $WK_PRICE_CALC_METHOD_EACH_DAY}{l s='/day'}{/if}{/if}

+

{$demand['name']|escape:'html':'UTF-8'} {if $product->show_price && !isset($restricted_country_mode) && !$PS_CATALOG_MODE}{convertPrice price = $demand['price']}{if $demand['price_calc_method'] == $WK_PRICE_CALC_METHOD_EACH_DAY}{l s='/night'}{/if}{/if}

{if isset($demand['adv_option']) && $demand['adv_option']}
@@ -136,8 +165,34 @@ + {capture name='adm_pcm_tooltip_content'} + {assign var="priceCalcMethod" value=$product['price_calculation_method']|default:0} +
+
+
    + {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} +
  • {l s='Check-in day'}
  • + {/if} + {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} +
  • {l s='During-stay days'}
  • + {/if} + {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} +
  • {l s='Check-out day'}
  • + {/if} +
+
+ {/capture} + {include file='helpers/tooltip.tpl' tooltip_content=$smarty.capture.adm_pcm_tooltip_content allow_html=true} + + {capture name='room_type_service_pcm_tooltip_content'} + {assign var="priceCalcMethod" value=$service['price_calculation_method']|default:0} +
+
+
    + {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} +
  • {l s='Check-in day'}
  • + {/if} + {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} +
  • {l s='During-stay days'}
  • + {/if} + {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} +
  • {l s='Check-out day'}
  • + {/if} +
+
+ {/capture} + {include file='helpers/tooltip.tpl' tooltip_content=$smarty.capture.room_type_service_pcm_tooltip_content allow_html=true} {if !$isRefundCompleted}
{l s='Total rooms cost'} {if $use_taxes && $display_tax_label == 1}{if $priceDisplay == 1}{l s='(tax excl.)'}{elseif $priceDisplay == 0}{l s='(tax incl.)'}{/if} {/if}
{displayPrice price=$demand['unit_price_tax_excl'] currency=$orderCurrency} {if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY} - {l s='/ night'} + {l s='/ day'} {/if} {displayPrice price=$demand['total_price_tax_excl'] currency=$orderCurrency} diff --git a/classes/Cart.php b/classes/Cart.php index ced44ff2d..d544f3cf9 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -827,7 +827,7 @@ class CartCore extends ObjectModel $serviceProducts = array(); $context = Context::getContext(); foreach ($productList as $key => $product) { - if (!$product['booking_product'] && Product::isSellableAsStandalone($product['selling_preference_type'])) { + if (!$product['booking_product'] && Product::isSellableAsStandalone($product['selling_preference_type'] && !Product::isSellableWithRoomType($product['selling_preference_type']))) { if (Validate::isLoadedObject( $objProduct = new Product($product['id_product'], false, $this->id_lang) )) { @@ -1756,124 +1756,102 @@ class CartCore extends ObjectModel $canSellWithRoomType = Product::isSellableWithRoomType($product['selling_preference_type']); $canSellWithHotel = Product::isSellableWithHotel($product['selling_preference_type']); $canSellAsStandalone = Product::isSellableAsStandalone($product['selling_preference_type']); + $isRoomServiceTotalType = in_array($type, array( + Cart::ONLY_ROOM_SERVICES, + Cart::ONLY_CONVENIENCE_FEE, + Cart::ONLY_ROOM_SERVICES_WITHOUT_AUTO_ADD, + Cart::ONLY_ROOM_SERVICES_WITHOUT_CONVENIENCE_FEE, + Cart::ONLY_ROOM_SERVICES_WITH_AUTO_ADD_WITHOUT_CONVENIENCE_FEE, + )); - if ($canSellAsStandalone - && (!$canSellWithHotel && !$canSellWithRoomType - || ($type == Cart::ONLY_STANDALONE_PRODUCTS && !$canSellWithHotel)) - ) { + if ($canSellAsStandalone && !$isRoomServiceTotalType) { $idHotelCartBooking = isset($product['id_hotel_cart_booking']) ? (int)$product['id_hotel_cart_booking'] : 0; $idHotel = isset($product['id_hotel']) ? (int)$product['id_hotel'] : 0; - if ($servicePorducts = $objServiceProductCartDetail->getServiceProductsInCart( + if ($serviceProducts = $objServiceProductCartDetail->getServiceProductsInCart( $this->id, [], - $idHotel, - $idHotelCartBooking, + 0, + 0, null, (int)$product['id_product'] )) { - foreach ($servicePorducts as $servicePorduct) { + foreach ($serviceProducts as $serviceProduct) { if ($with_taxes) { - $priceAdd = $servicePorduct['unit_price_tax_incl']; + $priceAdd = $serviceProduct['unit_price_tax_incl']; } else { - $priceAdd = $servicePorduct['unit_price_tax_excl']; + $priceAdd = $serviceProduct['unit_price_tax_excl']; } if ($ps_round_type == Order::ROUND_TOTAL) { - $products_total[$id_tax_rules_group.'_'.$id_address] += $priceAdd * (int)$servicePorduct['quantity']; + $products_total[$id_tax_rules_group.'_'.$id_address] += $priceAdd * (int)$serviceProduct['quantity']; } else { - $products_total[$id_tax_rules_group] += $priceAdd * (int)$servicePorduct['quantity']; + $products_total[$id_tax_rules_group] += $priceAdd * (int)$serviceProduct['quantity']; } + } } - } else if ($canSellWithHotel) { - $isRoomServiceTotalType = in_array($type, array( - Cart::ONLY_ROOM_SERVICES, - Cart::ONLY_CONVENIENCE_FEE, - Cart::ONLY_ROOM_SERVICES_WITHOUT_AUTO_ADD, - Cart::ONLY_ROOM_SERVICES_WITHOUT_CONVENIENCE_FEE, - Cart::ONLY_ROOM_SERVICES_WITH_AUTO_ADD_WITHOUT_CONVENIENCE_FEE, - )); - $id_hotel = null; - $id_hotel_cart_booking = null; - if ($param_product) { - if (isset($product['id_hotel']) && (int)$product['id_hotel']) { - $id_hotel = (int)$product['id_hotel']; - } - if (isset($product['id_hotel_cart_booking']) && (int)$product['id_hotel_cart_booking']) { - $id_hotel_cart_booking = (int)$product['id_hotel_cart_booking']; - } - } - - $servicePorducts = $objServiceProductCartDetail->getServiceProductsInCart( - $this->id, - [], - null, - null, - null, - (int)$product['id_product'] - ); - - if ($servicePorducts) { - foreach ($servicePorducts as $servicePorduct) { - if ($param_product) { - if ($id_hotel_cart_booking !== null - && (int)$servicePorduct['id_hotel_cart_booking'] !== $id_hotel_cart_booking - ) { - continue; - } - if ($id_hotel_cart_booking === null - && $id_hotel !== null - && ( - !empty($servicePorduct['id_hotel_cart_booking']) - || (int)$servicePorduct['id_hotel'] !== $id_hotel - ) - ) { - continue; - } - } - if ($isRoomServiceTotalType && empty($servicePorduct['id_hotel_cart_booking'])) { - continue; - } - if ($type == Cart::ONLY_STANDALONE_PRODUCTS - && !empty($servicePorduct['id_hotel_cart_booking']) - ) { - continue; - } - if ($with_taxes) { - $priceAdd = $servicePorduct['total_price_tax_incl']; - } else { - $priceAdd = $servicePorduct['total_price_tax_excl']; - } - - if ($ps_round_type == Order::ROUND_TOTAL) { - $products_total[$id_tax_rules_group.'_'.$id_address] += $priceAdd; - } else { - $products_total[$id_tax_rules_group] += $priceAdd; - } - } - } - } else if ($canSellWithRoomType) { - $isRoomServiceTotalType = in_array($type, array( - Cart::ONLY_ROOM_SERVICES, - Cart::ONLY_CONVENIENCE_FEE, - Cart::ONLY_ROOM_SERVICES_WITHOUT_AUTO_ADD, - Cart::ONLY_ROOM_SERVICES_WITHOUT_CONVENIENCE_FEE, - Cart::ONLY_ROOM_SERVICES_WITH_AUTO_ADD_WITHOUT_CONVENIENCE_FEE, - )); - - $idHotelCartBooking = null; - if ($param_product && isset($product['id_hotel_cart_booking'])) { - $idHotelCartBooking = (int)$product['id_hotel_cart_booking']; + } + if ($canSellWithHotel ) { + if ($type == Cart::ONLY_ROOM_SERVICES + || $type == Cart::ONLY_CONVENIENCE_FEE + || $type == Cart::ONLY_ROOM_SERVICES_WITHOUT_AUTO_ADD + || $type == Cart::ONLY_ROOM_SERVICES_WITHOUT_CONVENIENCE_FEE + || $type == Cart::ONLY_ROOM_SERVICES_WITH_AUTO_ADD_WITHOUT_CONVENIENCE_FEE + ) { + $serviceProducts = $objServiceProductCartDetail->getServiceProductsInCart( + $this->id, + [], + 0, + null, + null, + (int)$product['id_product'] + ); } elseif ($type == Cart::ONLY_STANDALONE_PRODUCTS) { - $idHotelCartBooking = 0; + $serviceProducts = $objServiceProductCartDetail->getServiceProductsInCart( + $this->id, + [], + null, + 0, + null, + (int)$product['id_product'] + ); + } else { + $serviceProducts = $objServiceProductCartDetail->getServiceProductsInCart( + $this->id, + [], + isset($product['id_hotel']) ? $product['id_hotel'] : null, + null, + null, + (int)$product['id_product'] + ); } + if ($serviceProducts) { + foreach ($serviceProducts as $serviceProduct) { + if(!empty($serviceProduct['id_hotel']) && empty($serviceProduct['id_hotel_cart_booking'])) { + if ($with_taxes) { + $priceAdd = $serviceProduct['total_price_tax_incl']; + } else { + $priceAdd = $serviceProduct['total_price_tax_excl']; + } + + if ($ps_round_type == Order::ROUND_TOTAL) { + $products_total[$id_tax_rules_group.'_'.$id_address] += $priceAdd; + } else { + $products_total[$id_tax_rules_group] += $priceAdd; + } + } + } + } + } + if ($canSellWithRoomType && $type !== Cart::ONLY_STANDALONE_PRODUCTS) { + if ($servicesWithRoom = $objServiceProductCartDetail->getServiceProductsInCart( $this->id, [], 0, - $idHotelCartBooking, + null, null, (int)$product['id_product'], null, @@ -1883,27 +1861,19 @@ class CartCore extends ObjectModel (int)$product['price_addition_type'] )) { foreach ($servicesWithRoom as $service) { - if ($param_product && $idHotelCartBooking !== null) { - if (!$idHotelCartBooking && !empty($service['id_hotel_cart_booking'])) { - continue; + if(!empty($service['id_hotel_cart_booking']) && empty($service['id_hotel'])) { + if ($with_taxes) { + $servicePrice = $service['total_price_tax_incl']; + } else { + $servicePrice = $service['total_price_tax_excl']; } - if ($idHotelCartBooking && (int)$service['id_hotel_cart_booking'] !== $idHotelCartBooking) { - continue; - } - } elseif ($isRoomServiceTotalType && empty($service['id_hotel_cart_booking'])) { - continue; - } - if ($with_taxes) { - $servicePrice = $service['total_price_tax_incl']; - } else { - $servicePrice = $service['total_price_tax_excl']; - } - // Rounding as per configurations - if ($ps_round_type == Order::ROUND_TOTAL) { - $products_total[$id_tax_rules_group.'_'.$id_address] += $servicePrice; - } else { - $products_total[$id_tax_rules_group] += $servicePrice; + // Rounding as per configurations + if ($ps_round_type == Order::ROUND_TOTAL) { + $products_total[$id_tax_rules_group.'_'.$id_address] += $servicePrice; + } else { + $products_total[$id_tax_rules_group] += $servicePrice; + } } } } @@ -2495,16 +2465,12 @@ class CartCore extends ObjectModel 'id_hotel_cart_booking' => $selectedProduct['id_hotel_cart_booking'], ); } - if (Product::PRICE_CALCULATION_METHOD_PER_DAY == $selectedProduct['price_calculation_method']) { - $numDays = HotelHelper::getNumberOfDays( - $selectedProduct['date_from'], - $selectedProduct['date_to'] - ); - $array[$selectedProduct['id_room_type_hotel']]['quantity'] += ($selectedProduct['quantity'] * $numDays); - } else { - $array[$selectedProduct['id_room_type_hotel']]['quantity'] += $selectedProduct['quantity']; - - } + $numDays = Product::getPriceCalculationApplicableDays( + $selectedProduct['price_calculation_method'], + $selectedProduct['date_from'], + $selectedProduct['date_to'] + ); + $array[$selectedProduct['id_room_type_hotel']]['quantity'] += ($selectedProduct['quantity'] * $numDays); } if ($array) { @@ -2512,8 +2478,8 @@ class CartCore extends ObjectModel $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'] / $selectedProduct['quantity']; - $product['price'] = $selectedProduct['total_price_tax_excl'] / $selectedProduct['quantity']; + $product['price_wt'] = $selectedProduct['total_price_tax_incl'] / max($selectedProduct['quantity'], 1); + $product['price'] = $selectedProduct['total_price_tax_excl'] / max($selectedProduct['quantity'], 1); $product['id_hotel'] = $selectedProduct['id_hotel']; $product['id_room_type'] = $selectedProduct['id_room_type']; $product['id_hotel_cart_booking'] = $selectedProduct['id_hotel_cart_booking']; diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index a022f3484..43158862f 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -505,7 +505,6 @@ abstract class PaymentModuleCore extends Module $objMail = new Mail(); $objServiceProductCartDetail = new ServiceProductCartDetail(); $cart_rules = $this->context->cart->getCartRules(); - foreach ($order_detail_list as $key => $order_detail) { /** @var OrderDetail $order_detail */ @@ -541,7 +540,6 @@ abstract class PaymentModuleCore extends Module $product_var_tpl_list = array(); $orderServiceProducts = array(); - $processedServiceProductCartIds = array(); $objProduct = new Product(); foreach ($order->product_list as $product) { @@ -970,11 +968,9 @@ abstract class PaymentModuleCore extends Module $objServiceProductCartDetail = new ServiceProductCartDetail(); foreach ($normalProducts as $product) { $idProduct = $product['id_product']; - $canSellWithRoomType = Product::isSellableWithRoomType($product['selling_preference_type']); - $canSellWithHotel = Product::isSellableWithHotel($product['selling_preference_type']); - $canSellAsStandalone = Product::isSellableAsStandalone($product['selling_preference_type']); + $productSellingType = $product['selling_preference_type']; - if ($canSellWithRoomType && !$canSellWithHotel && !$canSellAsStandalone) { + if (Product::isSellableWithRoomType($productSellingType)) { if ($roomTypeServices = $objServiceProductCartDetail->getServiceProductsInCart( $this->context->cart->id, [], @@ -983,16 +979,10 @@ abstract class PaymentModuleCore extends Module null, $product['id_product'] )) { - $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct( - $idProduct, - $order->id, - $product['selling_preference_type'] - ); + + $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct($idProduct, $order->id, $product['selling_preference_type']); foreach ($roomTypeServices as $roomTypeService) { - if (!Validate::isDate($roomTypeService['date_from']) - || !Validate::isDate($roomTypeService['date_to']) - || !(int) $roomTypeService['id_room_type'] - ) { + if (!$roomTypeService['id_hotel_cart_booking']) { continue; } $roomBookingDetail = $objBookingDetail->getRowByIdOrderIdProductInDateRange( @@ -1002,9 +992,6 @@ abstract class PaymentModuleCore extends Module $roomTypeService['date_to'], $roomTypeService['id_room'] ); - if (empty($roomBookingDetail['id'])) { - continue; - } $objServiceProductOrderDetail = new ServiceProductOrderDetail(); $objServiceProductOrderDetail->id_product = $idProduct; $objServiceProductOrderDetail->id_order = $order->id; @@ -1021,7 +1008,7 @@ abstract class PaymentModuleCore extends Module $objServiceProductOrderDetail->save(); } } - } elseif ($canSellWithHotel && !$canSellWithRoomType && !$canSellAsStandalone) { + } elseif (Product::isSellableWithHotel($productSellingType)) { if ($hotelProducts = $objServiceProductCartDetail->getServiceProductsInCart( $this->context->cart->id, [], @@ -1030,11 +1017,7 @@ abstract class PaymentModuleCore extends Module null, $product['id_product'] )) { - $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct( - $idProduct, - $order->id, - $product['selling_preference_type'] - ); + $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct($idProduct, $order->id, $product['selling_preference_type']); foreach ($hotelProducts as $hotelProduct) { $objServiceProductOrderDetail = new ServiceProductOrderDetail(); $objServiceProductOrderDetail->id_product = $idProduct; @@ -1056,9 +1039,10 @@ abstract class PaymentModuleCore extends Module } $objServiceProductOrderDetail->quantity = $hotelProduct['quantity']; $objServiceProductOrderDetail->save(); + } } - } elseif ($canSellAsStandalone && !$canSellWithRoomType && !$canSellWithHotel) { + } elseif (Product::isSellableAsStandalone($productSellingType)) { if ($standaloneProducts = $objServiceProductCartDetail->getServiceProductsInCart( $this->context->cart->id, [], @@ -1067,11 +1051,7 @@ abstract class PaymentModuleCore extends Module null, $product['id_product'] )) { - $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct( - $idProduct, - $order->id, - $product['selling_preference_type'] - ); + $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct($idProduct, $order->id, $product['selling_preference_type']); foreach ($standaloneProducts as $standaloneProduct) { $objServiceProductOrderDetail = new ServiceProductOrderDetail(); $objServiceProductOrderDetail->id_product = $idProduct; @@ -1089,7 +1069,7 @@ abstract class PaymentModuleCore extends Module $objServiceProductOrderDetail->save(); } } - } + } } } diff --git a/classes/Product.php b/classes/Product.php index dcf55eb40..f88ec4917 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -569,12 +569,10 @@ class ProductCore extends ObjectModel const PRICE_ADDITION_TYPE_WITH_ROOM = 1; const PRICE_ADDITION_TYPE_INDEPENDENT = 2; - const PRICE_CALCULATION_METHOD_PER_DAY = 1; - const PRICE_CALCULATION_METHOD_ONLY_CHECKIN_DAY = 1; const PRICE_CALCULATION_METHOD_ONLY_CHECKOUT_DAY = 2; - const PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY = 3; - const PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY = 4; + const PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY = 4; + const PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY = 3; const PRICE_CALCULATION_METHOD_CHECKIN_AND_DURINGSTAY = 5; const PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURINGSTAY = 6; const PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY = 7; @@ -6909,23 +6907,31 @@ class ProductCore extends ObjectModel return (int) $defaultDays; } + $checkin = 1; + $checkout = 1; + $duringStay = max($numNights - 1, 0); + switch ((int) $priceCalculationMethod) { case self::PRICE_CALCULATION_METHOD_ONLY_CHECKIN_DAY: + return $checkin; + case self::PRICE_CALCULATION_METHOD_ONLY_CHECKOUT_DAY: - return 1; + return $checkout; case self::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY: - return max($numNights - 1, 1); + return $duringStay; case self::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY: - return 2; + return $checkin + $checkout; case self::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURINGSTAY: + return $checkin + $duringStay; + case self::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURINGSTAY: - return $numNights; + return $checkout + $duringStay; case self::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY: - return $numNights + 1; + return $checkin + $checkout + $duringStay; default: return $numNights; diff --git a/classes/order/Order.php b/classes/order/Order.php index 0ed9581a3..26ee52823 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -47,9 +47,6 @@ class OrderCore extends ObjectModel const ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG = 3; - const SERVICE_PRODUCT_CONTEXT_ROOM_LINKED = 1; - const SERVICE_PRODUCT_CONTEXT_NON_ROOM = 2; - /** @var int Delivery address id */ public $id_address_delivery; @@ -2581,12 +2578,11 @@ class OrderCore extends ObjectModel )) { $totals = array_reduce($serviceProductDetail, function ($carry, $item) use ($order_detail) { $objHotelBookingDetail = new HotelBookingDetail((int) $item['id_htl_booking_detail']); - $numDays = 1; - if ((Product::PRICE_CALCULATION_METHOD_PER_DAY == $order_detail['product_price_calculation_method']) - && (!$numDays = HotelHelper::getNumberOfDays($objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to)) - ) { - $numDays = 1; - } + $numDays = Product::getPriceCalculationApplicableDays( + $order_detail['product_price_calculation_method'], + $objHotelBookingDetail->date_from, + $objHotelBookingDetail->date_to + ); if (!empty($item['id_tax_rules_group'])) { $qty = isset($item['quantity']) ? $item['quantity'] : 0; @@ -2637,12 +2633,11 @@ class OrderCore extends ObjectModel // We are getting auto added service for specific room.There will be only on htl_booking_detail but can have multiple auto added service with room. // Note: All the auto added service with room have same id_tax_rule group $autoAddedServiceData = array_shift($autoAddedServiceData); - $numDays = 1; - if ((Product::PRICE_CALCULATION_METHOD_PER_DAY == $order_detail['product_price_calculation_method']) - && (!$numDays = HotelHelper::getNumberOfDays($autoAddedServiceData['date_from'], $autoAddedServiceData['date_to'])) - ) { - $numDays = 1; - } + $numDays = Product::getPriceCalculationApplicableDays( + $order_detail['product_price_calculation_method'], + $autoAddedServiceData['date_from'], + $autoAddedServiceData['date_to'] + ); $autoAddedServices = $autoAddedServiceData['additional_services']; // Calculate total quantity of auto-added services diff --git a/classes/order/OrderDetail.php b/classes/order/OrderDetail.php index 3f37eeb1d..4b28d23ff 100644 --- a/classes/order/OrderDetail.php +++ b/classes/order/OrderDetail.php @@ -450,12 +450,11 @@ class OrderDetailCore extends ObjectModel $taxGroupInfo['id_room_type'], )) { $serviceProductData = array_shift($serviceProductData); - $numDays = 1; - if ((Product::PRICE_CALCULATION_METHOD_PER_DAY == $this->product_price_calculation_method) - && (!$numDays = HotelHelper::getNumberOfDays($serviceProductData['date_from'], $serviceProductData['date_to'])) - ) { - $numDays = 1; - } + $numDays = Product::getPriceCalculationApplicableDays( + $this->product_price_calculation_method, + $serviceProductData['date_from'], + $serviceProductData['date_to'] + ); $unit_price_tax_excl = array_reduce($serviceProductData['additional_services'], function ($unitPriceTaxExcl, $item) { return $unitPriceTaxExcl + (isset($item['unit_price_tax_excl']) ? $item['unit_price_tax_excl'] : 0); @@ -488,12 +487,11 @@ class OrderDetailCore extends ObjectModel $serviceProductData = array_shift($serviceProductData); - $numDays = 1; - if ((Product::PRICE_CALCULATION_METHOD_PER_DAY == $this->product_price_calculation_method) - && (!$numDays = HotelHelper::getNumberOfDays($serviceProductData['date_from'], $serviceProductData['date_to'])) - ) { - $numDays = 1; - } + $numDays = Product::getPriceCalculationApplicableDays( + $this->product_price_calculation_method, + $serviceProductData['date_from'], + $serviceProductData['date_to'] + ); $quantity = $quantity * $numDays; } diff --git a/classes/order/OrderInvoice.php b/classes/order/OrderInvoice.php index f97c589fc..457a0baa9 100644 --- a/classes/order/OrderInvoice.php +++ b/classes/order/OrderInvoice.php @@ -483,7 +483,7 @@ class OrderInvoiceCore extends ObjectModel return (!$v['is_booking_product'] && !$v['product_auto_add'] && Product::isSellableWithRoomType($v['selling_preference_type'])); }); - $details = $order->getProductTaxesDetails($order_detail, false); + $details = $order->getProductTaxesDetails($order_detail, false,Product::SELLING_PREFERENCE_WITH_ROOM_TYPE); if ($sum_composite_taxes) { $grouped_details = array(); @@ -550,7 +550,7 @@ class OrderInvoiceCore extends ObjectModel ); }); - $details = $order->getProductTaxesDetails($order_detail, false); + $details = $order->getProductTaxesDetails($order_detail, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE); if ($sum_composite_taxes) { $grouped_details = array(); @@ -609,8 +609,6 @@ class OrderInvoiceCore extends ObjectModel // - 'total_price_tax_excl' // - 'total_amount' $breakdown = array(); - $order_detail = array(); - $products = $this->getProducts(); $order_detail = $this->getProducts(); $order_detail = array_filter($order_detail, function($v) { return (!$v['is_booking_product'] && ( diff --git a/classes/webservice/WebserviceSpecificManagementBookings.php b/classes/webservice/WebserviceSpecificManagementBookings.php index ad3586d3b..e234ef7fa 100644 --- a/classes/webservice/WebserviceSpecificManagementBookings.php +++ b/classes/webservice/WebserviceSpecificManagementBookings.php @@ -1015,15 +1015,7 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We } } - $serviceProductPrice = $objOrder->getTotalProductsWithTaxes( - false, - false, - null, - null, - null, - [], - Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED - ); + $serviceProductPrice = $objOrder->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE); if ($demands = $objHotelBookingDemands->getExtraDemandsTaxesDetails($objOrder->id)) { $demandsPrice = array_sum(array_column($demands, 'total_price_tax_excl')); // Adding the tax @@ -1187,12 +1179,11 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We $objOrderDetail = new OrderDetail($service['id_order_detail']); $objServiceProductOrderDetail = new ServiceProductOrderDetail($service['id_service_product_order_detail']); $quantity = $objServiceProductOrderDetail->quantity; - if ($objOrderDetail->product_price_calculation_method == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $quantity = $quantity * HotelHelper::getNumberOfDays( - $objHotelBookingDetail->date_from, - $objHotelBookingDetail->date_to - ); - } + $quantity *= Product::getPriceCalculationApplicableDays( + $objOrderDetail->product_price_calculation_method, + $objHotelBookingDetail->date_from, + $objHotelBookingDetail->date_to + ); if (isset($this->wsRequestedRoomTypes[$dateRoomJoinKey]['services'][$service['id_product']])) { $oldPriceTaxExcl = $objServiceProductOrderDetail->total_price_tax_excl; diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index c38b6d896..2b8115761 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -1211,33 +1211,39 @@ class AdminCartsControllerCore extends AdminController $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE), $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE) ); + if ($serviceProducts) { + foreach ($serviceProducts as $key => $servProduct) { + if (!Product::isAvailableWhenOutOfStock(StockAvailable::outOfStock((int)$servProduct['id_product'])) + && Product::getQuantity((int)$servProduct['id_product']) <= 0 + ) { + unset($serviceProducts[$key]); + continue; + } + $numDays = Product::getPriceCalculationApplicableDays( + $servProduct['price_calculation_method'], + $dateFrom, + $dateTo + ); + + $serviceProducts[$key]['price_tax_exc'] = Product::getServiceProductPrice( + $servProduct['id_product'], + 0, + 0, + $idProduct, + false, + 1, + $dateFrom, + $dateTo, + $idCart + ) / max($numDays, 1); + } + } + } else { $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); $serviceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, false, 2, null); } - if ($serviceProducts) { - foreach ($serviceProducts as $key => $servProduct) { - $numDays = Product::getPriceCalculationApplicableDays( - $servProduct['price_calculation_method'], - $dateFrom, - $dateTo - ); - - $serviceProducts[$key]['price_tax_exc'] = Product::getServiceProductPrice( - $servProduct['id_product'], - 0, - 0, - $idProduct, - false, - 1, - $dateFrom, - $dateTo, - $idCart - )/$numDays; - } - } - $objServiceProductCartDetail = new ServiceProductCartDetail(); if ($selectedRoomServiceProduct = $objCartBookingData->getRoomRowByIdProductIdRoomInDateRange( $idCart, @@ -1381,6 +1387,7 @@ class AdminCartsControllerCore extends AdminController $idHotelCartBooking = Tools::getValue('id_hotel_cart_booking'); // valiadate services being added if (Validate::isLoadedObject($objHtlCartBooking = new HotelCartBookingData($idHotelCartBooking))) { + $objCart = new Cart($objHtlCartBooking->id_cart); $name = trim(Tools::getValue('new_service_name')); $price = Tools::getValue('new_service_price'); $priceCalcMethod = Tools::getValue('new_service_price_calc_method'); @@ -1415,6 +1422,15 @@ class AdminCartsControllerCore extends AdminController $response['hasError'] = true; $response['errors'][] = Tools::displayError('Invalid service name'); } + + if (empty($priceCalcMethod)) { + $response['hasError'] = true; + $response['errors'][] = Tools::displayError('Please select at least one price calculation method.'); + } elseif ( + !Validate::isUnsignedInt($priceCalcMethod)) { + $response['hasError'] = true; + $response['errors'][] = Tools::displayError('Invalid price calculation method.'); + } if (!isset($price)) { $response['hasError'] = true; @@ -1427,6 +1443,12 @@ class AdminCartsControllerCore extends AdminController // if no validation errors then add service if (!$response['hasError']) { // ======= START: Create Service product ========= + if ($objCart->id_currency != (int)Configuration::get('PS_CURRENCY_DEFAULT')) { + $currency = Currency::getCurrencyInstance($objCart->id_currency); + $price = Tools::ps_round($price/$currency->conversion_rate, 6); + $this->context->currency = new Currency((int) $objCart->id_currency); + } + $objServiceProduct = new Product(); $objServiceProduct->price_calculation_method = $priceCalcMethod; $objServiceProduct->selling_preference_type = Product::SELLING_PREFERENCE_WITH_ROOM_TYPE; @@ -1466,7 +1488,6 @@ class AdminCartsControllerCore extends AdminController RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE ); // If service product is create successfully the start adding the product in cart and order - $objCart = new Cart($objHtlCartBooking->id_cart); $objServiceProduct = new Product($objServiceProduct->id, false, $objCart->id_lang); $objServiceProductCartDetail = new ServiceProductCartDetail(); @@ -1539,16 +1560,32 @@ class AdminCartsControllerCore extends AdminController $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE), $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE) ); + if ($serviceProducts) { + foreach ($serviceProducts as $key => $servProduct) { + $numDays = Product::getPriceCalculationApplicableDays( + $servProduct['price_calculation_method'], + $objCartBookingData->date_from, + $objCartBookingData->date_to + ); + + $serviceProducts[$key]['price_tax_exc'] = Product::getServiceProductPrice( + $servProduct['id_product'], + 0, + 0, + $objCartBookingData->id_product, + false, + 1, + $objCartBookingData->date_from, + $objCartBookingData->date_to, + $objCartBookingData->id_cart + )/$numDays; + } + } } else { $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); $serviceProducts = $objRoomTypeServiceProduct->getServiceProductsData($objCartBookingData->id_product, 1, 0, false, 2, null); } - if ($serviceProducts) { - foreach ($serviceProducts as $key => $servProduct) { - $serviceProducts[$key]['price_tax_exc'] = $servProduct['price']; - } - } $objServiceProductCartDetail = new ServiceProductCartDetail(); if ($selectedRoomServiceProduct = $objCartBookingData->getRoomRowByIdProductIdRoomInDateRange( @@ -1632,6 +1669,39 @@ class AdminCartsControllerCore extends AdminController $response['hasError'] = true; $response['errors'][] = Tools::displayError('Invalid unit price for service').': '.$objProduct->name; } + + if ($selected && $objProduct->allow_multiple_quantity + && isset($serviceQuantities[$idServiceProduct]) + && Validate::isUnsignedInt($serviceQuantities[$idServiceProduct]) + ) { + $cartTotalQty = Cart::getProductQtyInCart($objCart->id, $idServiceProduct); + + $qty = (int)$serviceQuantities[$idServiceProduct]; + $numDays = Product::getPriceCalculationApplicableDays( + $objProduct->price_calculation_method, + $objHotelCartBookingData->date_from, + $objHotelCartBookingData->date_to + ); + + $existingQty = 0; + $objSpCartDetail = new ServiceProductCartDetail(); + if ($idExistingDetail = $objSpCartDetail->alreadyExists( + $objCart->id, + $idServiceProduct, + $idCartBooking + )) { + $existingQty = (int)(new ServiceProductCartDetail($idExistingDetail))->quantity * $numDays; + } + + $finalQty = (int)$cartTotalQty - $existingQty + ($qty * $numDays); + if ($objProduct->max_quantity && $finalQty > $objProduct->max_quantity) { + $response['hasError'] = true; + $response['errors'][] = Tools::displayError(sprintf('Cannot add more than %d quantity.', $objProduct->max_quantity)).': '.$objProduct->name; + } elseif (!Product::isAvailableWhenOutOfStock(StockAvailable::outOfStock((int)$idServiceProduct)) && !$objProduct->checkQty($finalQty)) { + $response['hasError'] = true; + $response['errors'][] = Tools::displayError('There isn\'t enough product in stock.').': '.$objProduct->name; + } + } } else { $response['errors'][] = Tools::displayError('Some services not found. please try after refreshing the page'); } diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index ba3dbb220..7bea0215f 100644 --- a/controllers/admin/AdminNormalProductsController.php +++ b/controllers/admin/AdminNormalProductsController.php @@ -227,7 +227,7 @@ class AdminNormalProductsControllerCore extends AdminController LEFT JOIN `'._DB_PREFIX_.'htl_room_type` hrt ON (rsp.`id_element` = hrt.`id_product` AND rsp.`element_type` = '.(int)RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE.') '.HotelBranchInformation::addHotelRestriction(false, 'hrt'); - $this->_select .= ' IF(a.`auto_add_to_cart`, "'.$this->l('Yes').'", "'.$this->l('No').'") as auto_added, IF(a.`auto_add_to_cart`, 1, 0) as badge_success, IF(a.`show_at_front`, "'.$this->l('Yes').'", "'.$this->l('No').'") as show_at_front_txt, CASE a.`price_calculation_method` WHEN '.Product::PRICE_CALCULATION_METHOD_ONLY_CHECKIN_DAY.' THEN "'.$this->l('Only check-in day').'" WHEN '.Product::PRICE_CALCULATION_METHOD_ONLY_CHECKOUT_DAY.' THEN "'.$this->l('Only check-out day').'" WHEN '.Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY.' THEN "'.$this->l('Only during-stay days').'" WHEN '.Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY.' THEN "'.$this->l('Check-in and check-out days').'" WHEN '.Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURINGSTAY.' THEN "'.$this->l('Check-in | during-stay days').'" WHEN '.Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURINGSTAY.' THEN "'.$this->l('Check-out | during-stay days').'" WHEN '.Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY.' THEN "'.$this->l('Check-in | check-out | during-stay days').'" ELSE "'.$this->l('Only check-in day').'" END as price_calculation_method_txt, (SELECT COUNT(hri.`id`) FROM `'._DB_PREFIX_.'htl_room_information` hri WHERE hri.`id_product` = a.`id_product`) as num_rooms, '; + $this->_select .= ' IF(a.`auto_add_to_cart`, "'.$this->l('Yes').'", "'.$this->l('No').'") as auto_added, IF(a.`auto_add_to_cart`, 1, 0) as badge_success, IF(a.`show_at_front`, "'.$this->l('Yes').'", "'.$this->l('No').'") as show_at_front_txt, (SELECT COUNT(hri.`id`) FROM `'._DB_PREFIX_.'htl_room_information` hri WHERE hri.`id_product` = a.`id_product`) as num_rooms, '; $this->_select .= ' COUNT(hrt.`id_product`) as products_associated, '; $this->_select .= 'shop.`name` AS `shopname`, a.`id_shop_default`, '; $this->_select .= $alias_image.'.`id_image` AS `id_image`, cl.`name` AS `name_category`, '.$alias.'.`price`, 0 AS `price_final`, a.`is_virtual`, pd.`nb_downloadable`, sav.`quantity` AS `sav_quantity`, '.$alias.'.`active`, IF(sav.`quantity`<=0, 1, 0) AS `badge_danger`'; @@ -302,13 +302,14 @@ class AdminNormalProductsControllerCore extends AdminController 'callback' => 'getPriceDisplayPreference', 'list' => $priceAdditionType, ); - $this->fields_list['price_calculation_method_txt'] = array( + $this->fields_list['price_calculation_method'] = array( 'title' => $this->l('Price calculation method'), 'filter_key' => 'a!price_calculation_method', 'type' => 'select', 'list' => $priceCalculationMethod, 'visible_default' => true, 'optional' => true, + 'callback' => 'getPriceCalculationMethod', ); $this->servicesCategory = array(); $idServiceCategory = Configuration::get('PS_SERVICE_CATEGORY'); @@ -432,23 +433,29 @@ class AdminNormalProductsControllerCore extends AdminController public function getBuyingOption($selling_preference_type, $row) { - if ($selling_preference_type == Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) { - return $this->l('With room type'); - } else if ($selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE) { - return $this->l('With hotel|room type'); - } else if ($selling_preference_type == Product::SELLING_PREFERENCE_STANDALONE) { - return $this->l('Standalone'); - } else if ($selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE) { - return $this->l('With hotel'); - } else if ($selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE) { - return $this->l('With hotel|standalone'); - } else if ($selling_preference_type == Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE) { - return $this->l('With room type|standalone'); - } else if ($selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE) { - return $this->l('With hotel|room type|standalone'); + $list = $this->fields_list['selling_preference_type']['list']; + + if (!isset($list[$selling_preference_type])) { + return '--'; } - return '--'; + $this->context->smarty->assign('selected_options', array_map('trim', explode('|', $list[$selling_preference_type]))); + + return $this->context->smarty->fetch('controllers/normal_products/selected_option.tpl'); + } + + public function getPriceCalculationMethod($txt, $row) + { + $list = $this->fields_list['price_calculation_method']['list']; + $method = (int)$row['price_calculation_method']; + + if (!isset($list[$method])) { + return '--'; + } + + $this->context->smarty->assign('selected_options', array_map('trim', explode('|', $list[$method]))); + + return $this->context->smarty->fetch('controllers/normal_products/selected_option.tpl'); } public function getHotelName($hotelName, $row) @@ -480,7 +487,7 @@ class AdminNormalProductsControllerCore extends AdminController .'template')) { $bo_theme = 'default'; } - + $this->addJqueryUI('ui.tooltip', 'base', true); $this->addJs(__PS_BASE_URI__.$this->admin_webpath.'/themes/'.$bo_theme.'/js/jquery.iframe-transport.js'); $this->addJs(__PS_BASE_URI__.$this->admin_webpath.'/themes/'.$bo_theme.'/js/jquery.fileupload.js'); $this->addJs(__PS_BASE_URI__.$this->admin_webpath.'/themes/'.$bo_theme.'/js/jquery.fileupload-process.js'); @@ -2360,6 +2367,14 @@ class AdminNormalProductsControllerCore extends AdminController $this->errors[] = $this->l('This product must be in the default category.'); } + if (!Tools::getValue('selling_preference_type')) { + $this->errors[] = $this->l('Please select at least one buying option.'); + } + + if (!Tools::getValue('price_calculation_method')) { + $this->errors[] = $this->l('Please select at least one price calculation method.'); + } + // Tags foreach ($languages as $language) { if ($value = Tools::getValue('tags_'.$language['id_lang'])) { diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 4739ab5d1..05c7a4f3c 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -996,25 +996,56 @@ class AdminOrdersControllerCore extends AdminController $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE), $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE), $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE) - ); - } else { - $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); - $serviceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, false, 2, null); - } + ); + + if($serviceProducts) { + foreach ($serviceProducts as $key => $servProduct) { + if (!Product::isAvailableWhenOutOfStock(StockAvailable::outOfStock((int)$servProduct['id_product'])) + && Product::getQuantity((int)$servProduct['id_product']) <= 0 + ) { + unset($serviceProducts[$key]); + continue; + } + if (!empty($additionalServices[$productLineData['id']]) + && in_array($servProduct['id_product'], array_column($additionalServices[$productLineData['id']]['additional_services'], 'id_product')) + ) { + unset($serviceProducts[$key]); + } else { - if ($serviceProducts) { - foreach ($serviceProducts as $key => $servProduct) { - $serviceProducts[$key]['price_tax_exc'] = $servProduct['price']; - if (isset($additionalServices[$productLineData['id']]) - && in_array($servProduct['id_product'], array_column($additionalServices[$productLineData['id']]['additional_services'], 'id_product')) - ) { - unset($serviceProducts[$key]); + $numDays = Product::getPriceCalculationApplicableDays( + $servProduct['price_calculation_method'], + $dateFrom, + $dateTo + ); + $serviceProducts[$key]['price_tax_exc'] = Product::getServiceProductPrice( + $servProduct['id_product'], + 0, + 0, + $idProduct, + false, + 1, + $dateFrom, + $dateTo + ) / max($numDays, 1); + } } } + } else { + $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); + if ($serviceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, false, 2, null)) { + foreach ($serviceProducts as $key => $servProduct) { + if (isset($additionalServices[$productLineData['id']]) + && in_array($servProduct['id_product'], array_column($additionalServices[$productLineData['id']]['additional_services'], 'id_product')) + ) { + unset($serviceProducts[$key]); + } + } - $smartyVars['serviceProducts'] = $serviceProducts; + } } + + $smartyVars['serviceProducts'] = $serviceProducts; $objOrderReturn = new OrderReturn(); $refundReqBookings = $objOrderReturn->getOrderRefundRequestedBookings($objOrder->id, 0, 1); $smartyVars['refundReqBookings'] = $refundReqBookings; @@ -5469,7 +5500,7 @@ class AdminOrdersControllerCore extends AdminController 1, $objBookingDetail->date_from, $objBookingDetail->date_to - ) / $numDays; + ) / max($numDays, 1); $unitPriceTaxExcl = Product::getServiceProductPrice( (int) $service['id_product'], 0, @@ -5479,7 +5510,7 @@ class AdminOrdersControllerCore extends AdminController 1, $objBookingDetail->date_from, $objBookingDetail->date_to - ) / $numDays; + ) / max($numDays, 1); $objServiceProductOrderDetail = new ServiceProductOrderDetail(); $objServiceProductOrderDetail->id_product = $service['id_product']; @@ -6235,61 +6266,67 @@ class AdminOrdersControllerCore extends AdminController && count($orderServiceProduct['additional_services']) ) { foreach ($orderServiceProduct['additional_services'] as $serviceProduct) { - if ($serviceProduct['price_calculation_method'] == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $newNumDays = HotelHelper::getNumberOfDays($new_date_from, $new_date_to); - $objServiceProductOrderDetail = new ServiceProductOrderDetail((int) $serviceProduct['id_service_product_order_detail']); - $unitPriceTaxExcl = $objServiceProductOrderDetail->unit_price_tax_excl; - $unitPriceTaxIncl = $objServiceProductOrderDetail->unit_price_tax_incl; + $newNumDays = Product::getPriceCalculationApplicableDays( + $serviceProduct['price_calculation_method'], + $new_date_from, + $new_date_to + ); + $oldNumDays = Product::getPriceCalculationApplicableDays( + $serviceProduct['price_calculation_method'], + $old_date_from, + $old_date_to + ); + $objServiceProductOrderDetail = new ServiceProductOrderDetail((int) $serviceProduct['id_service_product_order_detail']); + $unitPriceTaxExcl = $objServiceProductOrderDetail->unit_price_tax_excl; + $unitPriceTaxIncl = $objServiceProductOrderDetail->unit_price_tax_incl; - $newTotalPriceTaxExcl = Tools::processPriceRounding( - ($newNumDays * $unitPriceTaxExcl), - $objServiceProductOrderDetail->quantity, - $order->round_type, - $order->round_mode - ); - $newTotalPriceTaxIncl = Tools::processPriceRounding( - ($newNumDays * $unitPriceTaxIncl), - $objServiceProductOrderDetail->quantity, - $order->round_type, - $order->round_mode - ); + $newTotalPriceTaxExcl = Tools::processPriceRounding( + ($newNumDays * $unitPriceTaxExcl), + $objServiceProductOrderDetail->quantity, + $order->round_type, + $order->round_mode + ); + $newTotalPriceTaxIncl = Tools::processPriceRounding( + ($newNumDays * $unitPriceTaxIncl), + $objServiceProductOrderDetail->quantity, + $order->round_type, + $order->round_mode + ); - $order->total_products -= $objServiceProductOrderDetail->total_price_tax_excl; - $order->total_products_wt -= $objServiceProductOrderDetail->total_price_tax_incl; + $order->total_products -= $objServiceProductOrderDetail->total_price_tax_excl; + $order->total_products_wt -= $objServiceProductOrderDetail->total_price_tax_incl; - // change order total - $order->total_products += $newTotalPriceTaxExcl; - $order->total_products_wt += $newTotalPriceTaxIncl; + // change order total + $order->total_products += $newTotalPriceTaxExcl; + $order->total_products_wt += $newTotalPriceTaxIncl; - $objOrderDetail = new OrderDetail((int) $serviceProduct['id_order_detail']); - $objOrderDetail->total_price_tax_excl -= $objServiceProductOrderDetail->total_price_tax_excl; - $objOrderDetail->total_price_tax_incl -= $objServiceProductOrderDetail->total_price_tax_incl; + $objOrderDetail = new OrderDetail((int) $serviceProduct['id_order_detail']); + $objOrderDetail->total_price_tax_excl -= $objServiceProductOrderDetail->total_price_tax_excl; + $objOrderDetail->total_price_tax_incl -= $objServiceProductOrderDetail->total_price_tax_incl; - $objOrderDetail->total_price_tax_excl += $newTotalPriceTaxExcl; - $objOrderDetail->total_price_tax_incl += $newTotalPriceTaxIncl; + $objOrderDetail->total_price_tax_excl += $newTotalPriceTaxExcl; + $objOrderDetail->total_price_tax_incl += $newTotalPriceTaxIncl; - $oldNumDays = HotelHelper::getNumberOfDays($old_date_from, $old_date_to); - $oldProductQuantity = $objServiceProductOrderDetail->quantity * $oldNumDays; - $newProductQuantity = $objServiceProductOrderDetail->quantity * $newNumDays; - $objOrderDetail->product_quantity += ($newProductQuantity - $oldProductQuantity); + $oldProductQuantity = $objServiceProductOrderDetail->quantity * $oldNumDays; + $newProductQuantity = $objServiceProductOrderDetail->quantity * $newNumDays; + $objOrderDetail->product_quantity += ($newProductQuantity - $oldProductQuantity); - $objOrderDetail->save(); - $this->context->cart = new Cart($objServiceProductOrderDetail->id_cart); - $objOrderDetail->updateTaxAmount($order); + $objOrderDetail->save(); + $this->context->cart = new Cart($objServiceProductOrderDetail->id_cart); + $objOrderDetail->updateTaxAmount($order); - if (isset($order_invoice)) { - $order_invoice->total_paid_tax_excl -= $objServiceProductOrderDetail->total_price_tax_excl; - $order_invoice->total_paid_tax_incl -= $objServiceProductOrderDetail->total_price_tax_incl; + if (isset($order_invoice)) { + $order_invoice->total_paid_tax_excl -= $objServiceProductOrderDetail->total_price_tax_excl; + $order_invoice->total_paid_tax_incl -= $objServiceProductOrderDetail->total_price_tax_incl; - $order_invoice->total_paid_tax_excl += (float)$newTotalPriceTaxExcl; - $order_invoice->total_paid_tax_incl += (float)$newTotalPriceTaxIncl; - } - $objServiceProductOrderDetail->unit_price_tax_excl = $unitPriceTaxExcl; - $objServiceProductOrderDetail->unit_price_tax_incl = $unitPriceTaxIncl; - $objServiceProductOrderDetail->total_price_tax_excl = $newTotalPriceTaxExcl; - $objServiceProductOrderDetail->total_price_tax_incl = $newTotalPriceTaxIncl; - $objServiceProductOrderDetail->save(); + $order_invoice->total_paid_tax_excl += (float)$newTotalPriceTaxExcl; + $order_invoice->total_paid_tax_incl += (float)$newTotalPriceTaxIncl; } + $objServiceProductOrderDetail->unit_price_tax_excl = $unitPriceTaxExcl; + $objServiceProductOrderDetail->unit_price_tax_incl = $unitPriceTaxIncl; + $objServiceProductOrderDetail->total_price_tax_excl = $newTotalPriceTaxExcl; + $objServiceProductOrderDetail->total_price_tax_incl = $newTotalPriceTaxIncl; + $objServiceProductOrderDetail->save(); } } } @@ -6766,15 +6803,6 @@ class AdminOrdersControllerCore extends AdminController $order_invoice->total_discount_tax_excl = 0; $res &= $order_invoice->update(); } - - // If no rooms left in the order, Update Order total and discounts to 0 - $order->total_discounts = 0; - $order->total_discounts_tax_incl = 0; - $order->total_discounts_tax_excl = 0; - $order->total_paid = 0; - $order->total_paid_tax_incl = 0; - $order->total_paid_tax_excl = 0; - $order->update(); } // Assign to smarty informations in order to show the new product line @@ -7479,17 +7507,48 @@ class AdminOrdersControllerCore extends AdminController $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE), $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE) ); + if ($serviceProducts) { + foreach ($serviceProducts as $key => $servProduct) { + if (!Product::isAvailableWhenOutOfStock(StockAvailable::outOfStock((int)$servProduct['id_product'])) + && Product::getQuantity((int)$servProduct['id_product']) <= 0 + ) { + unset($serviceProducts[$key]); + continue; + } + if (!empty($additionalServices[$idHtlBookingDetail]) + && in_array($servProduct['id_product'], array_column($additionalServices[$idHtlBookingDetail]['additional_services'], 'id_product')) + ) { + unset($serviceProducts[$key]); + } else { + + $numDays = Product::getPriceCalculationApplicableDays( + $servProduct['price_calculation_method'], + $dateFrom, + $dateTo + ); + + $serviceProducts[$key]['price_tax_exc'] = Product::getServiceProductPrice( + $servProduct['id_product'], + 0, + 0, + $idProduct, + false, + 1, + $dateFrom, + $dateTo + ) / max($numDays, 1); + } + } + } + } else { $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); - $serviceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, false, 2, null); - } - - if ($serviceProducts) { - foreach ($serviceProducts as $key => $servProduct) { - $serviceProducts[$key]['price_tax_exc'] = $servProduct['price']; - if (isset($additionalServices[$idHtlBookingDetail]) && $additionalServices[$idHtlBookingDetail]) { - if (in_array($servProduct['id_product'], array_column($additionalServices[$idHtlBookingDetail]['additional_services'], 'id_product'))) { - unset($serviceProducts[$key]); + if ($serviceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, false, 2, null)) { + foreach ($serviceProducts as $key => $servProduct) { + if (!empty($additionalServices[$idHtlBookingDetail])) { + if (in_array($servProduct['id_product'], array_column($additionalServices[$idHtlBookingDetail]['additional_services'], 'id_product'))) { + unset($serviceProducts[$key]); + } } } } @@ -7643,13 +7702,11 @@ class AdminOrdersControllerCore extends AdminController $objServiceProductOrderDetail->quantity = $quantity; $objServiceProductOrderDetail->unit_price_tax_excl = $unitPrice; $objServiceProductOrderDetail->unit_price_tax_incl = $unitPrice * $oldTaxMultiplier; - $numDays = 1; - if ($objOrderDetail->product_price_calculation_method == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $numDays = HotelHelper::getNumberOfDays( - $objHotelBookingDetail->date_from, - $objHotelBookingDetail->date_to - ); - } + $numDays = Product::getPriceCalculationApplicableDays( + $objOrderDetail->product_price_calculation_method, + $objHotelBookingDetail->date_from, + $objHotelBookingDetail->date_to + ); $objServiceProductOrderDetail->total_price_tax_excl = Tools::processPriceRounding( ($objServiceProductOrderDetail->unit_price_tax_excl * $numDays), $quantity, @@ -7667,22 +7724,14 @@ class AdminOrdersControllerCore extends AdminController $priceDiffTaxExcl = $objServiceProductOrderDetail->total_price_tax_excl - $oldTotalPriceTaxExcl; $priceDiffTaxIncl = $objServiceProductOrderDetail->total_price_tax_incl - $oldTotalPriceTaxIncl; - if ($objOrderDetail->product_price_calculation_method == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $numDays = HotelHelper::getNumberOfDays( - $objHotelBookingDetail->date_from, - $objHotelBookingDetail->date_to - ); - $quantityDiff = ($objServiceProductOrderDetail->quantity - $oldQuantity)*$numDays; - } else { - $quantityDiff = $objServiceProductOrderDetail->quantity - $oldQuantity; - } + $quantityDiff = ($objServiceProductOrderDetail->quantity - $oldQuantity) * $numDays; $objOrderDetail->product_quantity += $quantityDiff; $objOrderDetail->total_price_tax_excl += $priceDiffTaxExcl; $objOrderDetail->total_price_tax_incl += $priceDiffTaxIncl; - $objOrderDetail->unit_price_tax_excl = ($objOrderDetail->total_price_tax_excl / $objOrderDetail->product_quantity); - $objOrderDetail->unit_price_tax_incl = ($objOrderDetail->total_price_tax_incl / $objOrderDetail->product_quantity); + $objOrderDetail->unit_price_tax_excl = ($objOrderDetail->total_price_tax_excl / max($objOrderDetail->product_quantity, 1)); + $objOrderDetail->unit_price_tax_incl = ($objOrderDetail->total_price_tax_incl / max($objOrderDetail->product_quantity, 1)); $result &= $objOrderDetail->updateTaxAmount($objOrder); @@ -7770,6 +7819,25 @@ class AdminOrdersControllerCore extends AdminController $response['hasError'] = true; $response['errors'][] = sprintf($this->l('Invalid unit price for %s.'), $objProduct->name); } + + if ($objProduct->allow_multiple_quantity && Validate::isUnsignedInt($qty[$service])) { + $finalQty = (int)$qty[$service]; + $numDays = Product::getPriceCalculationApplicableDays( + Product::getProductPriceCalculation($service), + $objHotelBookingDetail->date_from, + $objHotelBookingDetail->date_to + ); + $stockQty = $finalQty * $numDays; + + if ($objProduct->max_quantity && $finalQty > $objProduct->max_quantity) { + $response['hasError'] = true; + $response['errors'][] = sprintf($this->l('Cannot add more than %d quantity.'), $objProduct->max_quantity).': '.$objProduct->name; + } elseif (!Product::isAvailableWhenOutOfStock(StockAvailable::outOfStock((int)$service)) && !$objProduct->checkQty($stockQty)) { + $response['hasError'] = true; + $response['errors'][] = $this->l('There isn\'t enough product in stock.').': '.$objProduct->name; + } + } + $selectedServices[$key] = array( 'id' => $service, 'qty' => $qty[$service], @@ -7826,7 +7894,7 @@ class AdminOrdersControllerCore extends AdminController 1, $objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to - ) / $numDays; + ) / max($numDays, 1); if ($initialServicePrice != $service['price']) { $specific_price = new SpecificPrice(); @@ -7887,7 +7955,7 @@ class AdminOrdersControllerCore extends AdminController 1, null, $roomHtlCartInfo['id'] - ) / $numDays; + ) / max($numDays, 1); $unitPriceTaxIncl = Product::getServiceProductPrice( (int) $product['id_product'], 0, @@ -7902,7 +7970,7 @@ class AdminOrdersControllerCore extends AdminController 1, null, $roomHtlCartInfo['id'] - ) / $numDays; + ) / max($numDays, 1); $totalPriceChangeTaxExcl += $totalPriceTaxExcl = Tools::processPriceRounding( ($unitPriceTaxExcl * $numDays), @@ -8047,6 +8115,15 @@ class AdminOrdersControllerCore extends AdminController $response['errors'][] = Tools::displayError('Invalid service name'); } + if (empty($priceCalcMethod)) { + $response['hasError'] = true; + $response['errors'][] = Tools::displayError('Please select at least one price calculation method.'); + } elseif ( + !Validate::isUnsignedInt($priceCalcMethod)) { + $response['hasError'] = true; + $response['errors'][] = Tools::displayError('Invalid price calculation method.'); + } + if (!isset($price)) { $response['hasError'] = true; $response['errors'][] = Tools::displayError('Service price is required'); @@ -8054,7 +8131,6 @@ class AdminOrdersControllerCore extends AdminController $response['hasError'] = true; $response['errors'][] = Tools::displayError('Invalid service price'); } - // if no validation errors then add service if (!$response['hasError']) { // ======= START: Create Service product ========= @@ -8164,7 +8240,7 @@ class AdminOrdersControllerCore extends AdminController $objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to, $objCart->id - ) / $numDays; + ) / max($numDays, 1); $unitPriceTaxIncl = Product::getServiceProductPrice( (int)$product['id_product'], 0, @@ -8175,7 +8251,7 @@ class AdminOrdersControllerCore extends AdminController $objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to, $objCart->id - ) / $numDays; + ) / max($numDays, 1); $totalPriceChangeTaxExcl += $totalPriceTaxExcl = Tools::processPriceRounding( ($unitPriceTaxExcl * $numDays), @@ -8358,13 +8434,12 @@ class AdminOrdersControllerCore extends AdminController if ($res &= $objServiceProductOrderDetail->delete()) { $order = new Order($objServiceProductOrderDetail->id_order); - if ($objOrderDetail->product_price_calculation_method == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $numDays = HotelHelper::getNumberOfDays( - $objHotelBookingDetail->date_from, - $objHotelBookingDetail->date_to - ); - $quantity = $quantity * $numDays; - } + $numDays = Product::getPriceCalculationApplicableDays( + $objOrderDetail->product_price_calculation_method, + $objHotelBookingDetail->date_from, + $objHotelBookingDetail->date_to + ); + $quantity = $quantity * $numDays; if ($quantity >= $objOrderDetail->product_quantity) { $objOrderDetail->delete(); } else { diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 0a7acb76f..7c8c20efc 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -415,9 +415,12 @@ class AdminProductsControllerCore extends AdminController ); $objProduct = new Product(); - $hotelServiceProducts = $objProduct->getServiceProducts(null, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE); - $roomTypeServiceProducts = $objProduct->getServiceProducts(null, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE); - $allServiceProducts = array_merge($roomTypeServiceProducts, $hotelServiceProducts); + $allServiceProducts = array_values(array_filter( + $objProduct->getServiceProducts(null), + function ($serviceProduct) { + return Product::isSellableWithRoomType($serviceProduct['selling_preference_type']); + } + )); $serviceProducts = array(); foreach ($allServiceProducts as $serviceProduct) { $serviceProducts[$serviceProduct['id_product']] = $serviceProduct['name']; @@ -3152,9 +3155,12 @@ class AdminProductsControllerCore extends AdminController $objRoomType = new HotelRoomType(); if ($hotelRoomType = $objRoomType->getRoomTypeInfoByIdProduct($obj->id)) { - $hotelServiceProducts = $obj->getServiceProducts(null, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE); - $roomTypeServiceProducts = $obj->getServiceProducts(null, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE); - $allServiceProducts = array_merge($roomTypeServiceProducts, $hotelServiceProducts); + $allServiceProducts = array_values(array_filter( + $obj->getServiceProducts(null), + function ($serviceProduct) { + return Product::isSellableWithRoomType($serviceProduct['selling_preference_type']); + } + )); $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); $objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice(); diff --git a/controllers/admin/AdminStatsController.php b/controllers/admin/AdminStatsController.php index ba6b3b371..95ee79919 100644 --- a/controllers/admin/AdminStatsController.php +++ b/controllers/admin/AdminStatsController.php @@ -2304,9 +2304,9 @@ class AdminStatsControllerCore extends AdminStatsTabController IFNULL(SUM( CASE WHEN od.`purchase_supplier_price` <> "0.000000" - THEN (od.`purchase_supplier_price` / (IF (od.`product_price_calculation_method` = '.Product::PRICE_CALCULATION_METHOD_PER_BOOKING.', DATEDIFF(hbd.`date_to`, hbd.`date_from`), 1))) + THEN (od.`purchase_supplier_price` / (IF (od.`product_price_calculation_method` = '.Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY.', DATEDIFF(hbd.`date_to`, hbd.`date_from`), 1))) WHEN od.`purchase_supplier_price` = "0.000000" - THEN ((od.`original_product_price` / o.`conversion_rate`) * '.(int)Configuration::get('CONF_AVERAGE_PRODUCT_MARGIN').' / 100) / (IF (od.`product_price_calculation_method` = '.Product::PRICE_CALCULATION_METHOD_PER_BOOKING.', DATEDIFF(hbd.`date_to`, hbd.`date_from`), 1)) + THEN ((od.`original_product_price` / o.`conversion_rate`) * '.(int)Configuration::get('CONF_AVERAGE_PRODUCT_MARGIN').' / 100) / (IF (od.`product_price_calculation_method` = '.Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY.', DATEDIFF(hbd.`date_to`, hbd.`date_from`), 1)) END ), 0) FROM `'._DB_PREFIX_.'service_product_order_detail` rtspod diff --git a/controllers/front/CartController.php b/controllers/front/CartController.php index 98fb6eaac..67ee06439 100644 --- a/controllers/front/CartController.php +++ b/controllers/front/CartController.php @@ -482,7 +482,11 @@ class CartControllerCore extends FrontController if ($product->allow_multiple_quantity) { $finalQuantity = $this->qty; if (isset($productCartDetail) && $productCartDetail) { - $finalQuantity += $productCartDetail['quantity']; + $quantityInCart = Cart::getProductQtyInCart( + $id_cart, + $this->id_product + ); + $finalQuantity += $quantityInCart; } if ($product->max_quantity && $finalQuantity > $product->max_quantity) { $this->errors[] = Tools::displayError(sprintf('You cannot add more than %d quantity for this product in the cart.', $product->max_quantity)); @@ -560,22 +564,24 @@ class CartControllerCore extends FrontController } } - // Check product quantity availability - if ($this->id_product_attribute) { - if (!Product::isAvailableWhenOutOfStock($product->out_of_stock) && !ProductAttribute::checkAttributeQty($this->id_product_attribute, $qty_to_check)) { + // Check product quantity availability only when no earlier validation error exists + if (!$this->errors) { + if ($this->id_product_attribute) { + if (!Product::isAvailableWhenOutOfStock($product->out_of_stock) && !ProductAttribute::checkAttributeQty($this->id_product_attribute, $qty_to_check)) { + $this->errors[] = Tools::displayError('There isn\'t enough product in stock.', !Tools::getValue('ajax')); + } + } elseif ($product->hasAttributes()) { + $minimumQuantity = ($product->out_of_stock == 2) ? !Configuration::get('PS_ORDER_OUT_OF_STOCK') : !$product->out_of_stock; + $this->id_product_attribute = Product::getDefaultAttribute($product->id, $minimumQuantity); + // @todo do something better than a redirect admin !! + if (!$this->id_product_attribute) { + Tools::redirectAdmin($this->context->link->getProductLink($product)); + } elseif (!Product::isAvailableWhenOutOfStock($product->out_of_stock) && !ProductAttribute::checkAttributeQty($this->id_product_attribute, $qty_to_check)) { + $this->errors[] = Tools::displayError('There isn\'t enough product in stock.', !Tools::getValue('ajax')); + } + } elseif (!$product->checkQty($qty_to_check)) { $this->errors[] = Tools::displayError('There isn\'t enough product in stock.', !Tools::getValue('ajax')); } - } elseif ($product->hasAttributes()) { - $minimumQuantity = ($product->out_of_stock == 2) ? !Configuration::get('PS_ORDER_OUT_OF_STOCK') : !$product->out_of_stock; - $this->id_product_attribute = Product::getDefaultAttribute($product->id, $minimumQuantity); - // @todo do something better than a redirect admin !! - if (!$this->id_product_attribute) { - Tools::redirectAdmin($this->context->link->getProductLink($product)); - } elseif (!Product::isAvailableWhenOutOfStock($product->out_of_stock) && !ProductAttribute::checkAttributeQty($this->id_product_attribute, $qty_to_check)) { - $this->errors[] = Tools::displayError('There isn\'t enough product in stock.', !Tools::getValue('ajax')); - } - } elseif (!$product->checkQty($qty_to_check)) { - $this->errors[] = Tools::displayError('There isn\'t enough product in stock.', !Tools::getValue('ajax')); } // If no errors, process product addition @@ -748,8 +754,20 @@ class CartControllerCore extends FrontController if ($objProduct->allow_multiple_quantity) { if (!Validate::isUnsignedInt($qty)) { $this->errors[] = Tools::displayError('The quantity you\'ve entered is invalid.'); - } elseif ($objProduct->max_quantity && $qty > $objProduct->max_quantity) { - $this->errors[] = Tools::displayError(sprintf('cannot add more than %d quantity.', $objProduct->max_quantity)); + } else { + $cartTotalQty = Cart::getProductQtyInCart((int)$this->context->cart->id,(int)$idServiceProduct); + $numDays = Product::getPriceCalculationApplicableDays( + $objProduct->price_calculation_method, + $objHotelCartBookingData->date_from, + $objHotelCartBookingData->date_to + ); + $currentQty = $qty * $numDays; + $finalQty = (int)$cartTotalQty + $currentQty; + if ($objProduct->max_quantity && $finalQty > $objProduct->max_quantity) { + $this->errors[] = Tools::displayError(sprintf('cannot add more than %d quantity.', $objProduct->max_quantity)); + } else if (!Product::isAvailableWhenOutOfStock($objProduct->out_of_stock) && !$objProduct->checkQty($finalQty)) { + $this->errors[] = Tools::displayError('There isn\'t enough product in stock.'); + } } } else { $qty = 1; diff --git a/controllers/front/GuestTrackingController.php b/controllers/front/GuestTrackingController.php index fd684953b..3b6fd2b2b 100644 --- a/controllers/front/GuestTrackingController.php +++ b/controllers/front/GuestTrackingController.php @@ -524,10 +524,7 @@ class GuestTrackingControllerCore extends FrontController 1 ); } - } else if ( - Product::isSellableWithHotel($type_value['selling_preference_type']) - || Product::isSellableAsStandalone($type_value['selling_preference_type']) - ) { + } else if (Product::isSellableWithHotel($type_value['selling_preference_type'])) { $cover_image_arr = $product->getCover($type_value['product_id']); if (!empty($cover_image_arr)) { @@ -535,21 +532,21 @@ class GuestTrackingControllerCore extends FrontController } else { $type_value['cover_img'] = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code.'-default', 'small_default'); } + $hotelProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($idOrder, $type_value['id_order_detail'], $type_value['product_id']); + foreach ($hotelProducts as $hotelProduct) { + $hotelServiceProducts[] = array_merge($type_value, $hotelProduct); + } + } else if (Product::isSellableAsStandalone($type_value['selling_preference_type'])) { + $cover_image_arr = $product->getCover($type_value['product_id']); - $serviceProducts = $objServiceProductOrderDetail->getServiceProductsInOrder( - $idOrder, - $type_value['id_order_detail'], - $type_value['product_id'] - ); - foreach ($serviceProducts as $serviceProduct) { - $isStandaloneRow = empty($serviceProduct['id_hotel']) && empty($serviceProduct['id_htl_booking_detail']); - $isHotelRow = !empty($serviceProduct['id_hotel']) && empty($serviceProduct['id_htl_booking_detail']); - - if ($isHotelRow && Product::isSellableWithHotel($type_value['selling_preference_type'])) { - $hotelServiceProducts[] = array_merge($type_value, $serviceProduct); - } elseif ($isStandaloneRow && Product::isSellableAsStandalone($type_value['selling_preference_type'])) { - $standaloneServiceProducts[] = array_merge($type_value, $serviceProduct); - } + if (!empty($cover_image_arr)) { + $type_value['cover_img'] = $this->context->link->getImageLink($product->link_rewrite, $product->id.'-'.$cover_image_arr['id_image'], 'small_default'); + } else { + $type_value['cover_img'] = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code.'-default', 'small_default'); + } + $standaloneProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($idOrder, $type_value['id_order_detail'], $type_value['product_id']); + foreach ($standaloneProducts as $standaloneProduct) { + $standaloneServiceProducts[] = array_merge($type_value, $standaloneProduct); } } } diff --git a/controllers/front/OrderConfirmationController.php b/controllers/front/OrderConfirmationController.php index 44940f97d..e40a7bec0 100644 --- a/controllers/front/OrderConfirmationController.php +++ b/controllers/front/OrderConfirmationController.php @@ -149,6 +149,7 @@ class OrderConfirmationControllerCore extends FrontController $cart_standalone_service_products = array(); $cart_hotel_service_products = array(); $cart_htl_data = array(); + foreach ($cartOrders as $cartOrder) { $idOrder = $cartOrder['id_order']; $objCartOrder = new Order($idOrder); @@ -298,7 +299,7 @@ class OrderConfirmationControllerCore extends FrontController if (empty($cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_ti'])) { $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_ti'] = 0; } - $additionalServicesPriceTI = $objServiceProductOrderDetail->getRoomTypeServiceProducts( + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_ti'] += $extraDemandPriceTI = $objServiceProductOrderDetail->getRoomTypeServiceProducts( $idOrder, 0, 0, @@ -310,12 +311,10 @@ class OrderConfirmationControllerCore extends FrontController 1, 0 ); - $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_ti'] += $additionalServicesPriceTI; - $orderTotalInfo['total_services_ti'] += $additionalServicesPriceTI; if (empty($cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_te'])) { $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_te'] = 0; } - $additionalServicesPriceTE = $objServiceProductOrderDetail->getRoomTypeServiceProducts( + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_te'] += $extraDemandPriceTE = $objServiceProductOrderDetail->getRoomTypeServiceProducts( $idOrder, 0, 0, @@ -327,13 +326,11 @@ class OrderConfirmationControllerCore extends FrontController 0, 0 ); - $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_te'] += $additionalServicesPriceTE; - $orderTotalInfo['total_services_te'] += $additionalServicesPriceTE; // get auto added price to be displayed with room price if (empty($cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'])) { $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = 0; } - $autoAddedServicesPriceTI = $objServiceProductOrderDetail->getRoomTypeServiceProducts( + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] += $objServiceProductOrderDetail->getRoomTypeServiceProducts( $idOrder, 0, 0, @@ -346,12 +343,10 @@ class OrderConfirmationControllerCore extends FrontController 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM ); - $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] += $autoAddedServicesPriceTI; - $orderTotalInfo['total_auto_add_services_ti'] += $autoAddedServicesPriceTI; if (empty($cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'])) { $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] = 0; } - $autoAddedServicesPriceTE = $objServiceProductOrderDetail->getRoomTypeServiceProducts( + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] += $objServiceProductOrderDetail->getRoomTypeServiceProducts( $idOrder, 0, 0, @@ -364,16 +359,10 @@ class OrderConfirmationControllerCore extends FrontController 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM ); - $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] += $autoAddedServicesPriceTE; - $orderTotalInfo['total_auto_add_services_te'] += $autoAddedServicesPriceTE; $totalRoomsBooked += 1; } - } else { - $canSellWithRoomType = Product::isSellableWithRoomType($type_value['selling_preference_type']); - $canSellWithHotel = Product::isSellableWithHotel($type_value['selling_preference_type']); - $canSellAsStandalone = Product::isSellableAsStandalone($type_value['selling_preference_type']); - + } else if (Product::isSellableWithHotel($type_value['selling_preference_type'])) { $cover_image_arr = $product->getCover($type_value['product_id']); if (!empty($cover_image_arr)) { @@ -383,43 +372,36 @@ class OrderConfirmationControllerCore extends FrontController } $serviceProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($idOrder, $type_value['id_order_detail'], $type_value['product_id']); foreach ($serviceProducts as $serviceProduct) { - $idHotel = (int)$serviceProduct['id_hotel']; - $isRoomLinked = !empty($serviceProduct['id_htl_booking_detail']); + $type_value['total_price_tax_excl'] = $serviceProduct['total_price_tax_excl']; + $type_value['total_price_tax_incl'] = $serviceProduct['total_price_tax_incl']; + $type_value['product_quantity'] = $serviceProduct['quantity']; + $type_value['option_name'] = $serviceProduct['option_name']; + $type_value['location'] = $serviceProduct['option_name']; - $serviceLine = $type_value; - $serviceLine['unit_price_tax_excl'] = $serviceProduct['unit_price_tax_excl']; - $serviceLine['unit_price_tax_incl'] = $serviceProduct['unit_price_tax_incl']; - $serviceLine['total_price_tax_excl'] = $serviceProduct['total_price_tax_excl']; - $serviceLine['total_price_tax_incl'] = $serviceProduct['total_price_tax_incl']; - $serviceLine['product_quantity'] = $serviceProduct['quantity']; - $serviceLine['option_name'] = $serviceProduct['option_name']; - - if ( - $canSellWithRoomType - && (int)$type_value['product_auto_add'] == 1 - && (int)$type_value['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT - ) { - $orderTotalInfo['total_convenience_fee_ti'] += $serviceLine['total_price_tax_incl']; - $orderTotalInfo['total_convenience_fee_te'] += $serviceLine['total_price_tax_excl']; - continue; + if ($hotelInfo = $objHtlBranchInfo->hotelBranchesInfo($this->context->language->id, 2, 1, $serviceProduct['id_hotel'])) { + $type_value['hotel_location'] = $hotelInfo['hotel_name'].', '.$hotelInfo['city']. + ($hotelInfo['state_name']?', '.$hotelInfo['state_name']:'').', '. + $hotelInfo['country_name'].', '.$hotelInfo['postcode']; } + $cart_hotel_service_products[] = $type_value; + } + } else if (Product::isSellableAsStandalone($type_value['selling_preference_type'])) { + $cover_image_arr = $product->getCover($type_value['product_id']); - if ($canSellWithHotel && $idHotel) { - $serviceLine['location'] = $serviceProduct['option_name']; - if ($hotelInfo = $objHtlBranchInfo->hotelBranchesInfo($this->context->language->id, 2, 1, $idHotel)) { - $serviceLine['hotel_location'] = $hotelInfo['hotel_name'].', '.$hotelInfo['city']. - ($hotelInfo['state_name']?', '.$hotelInfo['state_name']:'').', '. - $hotelInfo['country_name'].', '.$hotelInfo['postcode']; - } - $cart_hotel_service_products[] = $serviceLine; - } elseif ($canSellAsStandalone && !$idHotel && !$isRoomLinked) { - $cart_standalone_service_products[] = $serviceLine; - } else { - continue; - } - - $orderTotalInfo['total_standalone_products_ti'] += $serviceLine['total_price_tax_incl']; - $orderTotalInfo['total_standalone_products_te'] += $serviceLine['total_price_tax_excl']; + if (!empty($cover_image_arr)) { + $type_value['cover_img'] = $this->context->link->getImageLink($product->link_rewrite, $product->id.'-'.$cover_image_arr['id_image'], 'small_default'); + } else { + $type_value['cover_img'] = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code.'-default', 'small_default'); + } + $serviceProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($idOrder, $type_value['id_order_detail'], $type_value['product_id']); + foreach ($serviceProducts as $serviceProduct) { + $type_value['unit_price_tax_excl'] = $serviceProduct['unit_price_tax_excl']; + $type_value['unit_price_tax_incl'] = $serviceProduct['unit_price_tax_incl']; + $type_value['total_price_tax_excl'] = $serviceProduct['total_price_tax_excl']; + $type_value['total_price_tax_incl'] = $serviceProduct['total_price_tax_incl']; + $type_value['product_quantity'] = $serviceProduct['quantity']; + $type_value['option_name'] = $serviceProduct['option_name']; + $cart_standalone_service_products[] = $type_value; } } } @@ -433,9 +415,17 @@ class OrderConfirmationControllerCore extends FrontController if (!$objCartOrder->hasInvoice()) { $orders_has_invoice = 0; } + $orderTotalInfo['total_standalone_products_ti'] += ($objCartOrder->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE)+$objCartOrder->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE)); + $orderTotalInfo['total_standalone_products_te'] += ($objCartOrder->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE)+$objCartOrder->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE)); $orderTotalInfo['total_wrapping'] += $objCartOrder->total_wrapping; $orderTotalInfo['total_rooms_te'] += $objCartOrder->getTotalProductsWithoutTaxes(false, true); $orderTotalInfo['total_rooms_ti'] += $objCartOrder->getTotalProductsWithTaxes(false, true); + $orderTotalInfo['total_auto_add_services_te'] += $objCartOrder->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM); + $orderTotalInfo['total_auto_add_services_ti'] += $objCartOrder->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM); + $orderTotalInfo['total_services_te'] += $objCartOrder->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 0); + $orderTotalInfo['total_services_ti'] += $objCartOrder->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 0); + $orderTotalInfo['total_convenience_fee_te'] += $objCartOrder->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT); + $orderTotalInfo['total_convenience_fee_ti'] += $objCartOrder->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT); $orderTotalInfo['total_discounts'] += $objCartOrder->total_discounts; $orderTotalInfo['total_discounts_te'] += $objCartOrder->total_discounts_tax_excl; @@ -481,6 +471,7 @@ class OrderConfirmationControllerCore extends FrontController $this->setTemplate(_PS_THEME_DIR_.'order-confirmation.tpl'); } + /** * Execute the hook displayPaymentReturn */ diff --git a/controllers/front/OrderDetailController.php b/controllers/front/OrderDetailController.php index 98e979865..c71439dab 100644 --- a/controllers/front/OrderDetailController.php +++ b/controllers/front/OrderDetailController.php @@ -101,7 +101,6 @@ class OrderDetailControllerCore extends FrontController $total_convenience_fee_te = 0; $total_convenience_fee_ti = 0; $roomTypes = array(); - $processedConvenienceFeeProducts = array(); $objOrderReturn = new OrderReturn(); $refundedAmount = 0; $refundedAmount = $objOrderReturn->getRefundedAmount($order->id); @@ -359,17 +358,8 @@ class OrderDetailControllerCore extends FrontController $value['avg_price_diff_tax_excl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_excl'] - $value['product_price_tax_excl'], 6)); $value['avg_price_diff_tax_incl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_incl'] - $value['product_price_tax_incl'], 6)); } - } else { - $canSellWithRoomType = Product::isSellableWithRoomType($type_value['selling_preference_type']); - $canSellWithHotel = Product::isSellableWithHotel($type_value['selling_preference_type']); - $canSellAsStandalone = Product::isSellableAsStandalone($type_value['selling_preference_type']); - - if ($canSellWithRoomType - && $type_value['product_auto_add'] - && $type_value['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT - && !isset($processedConvenienceFeeProducts[$type_value['product_id']]) - ) { - $processedConvenienceFeeProducts[$type_value['product_id']] = true; + } else if (Product::isSellableWithRoomType($type_value['selling_preference_type'])) { + if ($type_value['product_auto_add'] && $type_value['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT) { $total_convenience_fee_ti += $objServiceProductOrderDetail->getRoomTypeServiceProducts( $id_order, $type_value['product_id'], @@ -395,50 +385,37 @@ class OrderDetailControllerCore extends FrontController 1 ); } - - if ($canSellWithHotel || $canSellAsStandalone) { - $serviceProducts = $objServiceProductOrderDetail->getServiceProductsInOrder( - $id_order, - $type_value['id_order_detail'], - $type_value['product_id'] - ); - - foreach ($serviceProducts as $serviceProduct) { - $idHotel = (int)$serviceProduct['id_hotel']; - $isRoomLinked = !empty($serviceProduct['id_htl_booking_detail']); - - // Room-linked rows are already included in room detail block. - if ($isRoomLinked) { - continue; - } - - if ($canSellWithHotel && $idHotel) { - $hotelProduct = array_merge($type_value, $serviceProduct); - $hotelServiceProducts[] = $hotelProduct; - $formattedProduct = $serviceProduct; - $formattedProduct['refund_denied'] = 0; - if (isset($serviceProduct['refund_info']) - && ($serviceProduct['refund_info']['refunded'] && !$serviceProduct['refund_info']['id_customization']) - ) { - $formattedProduct['refund_denied'] = 1; - } - } elseif ($canSellAsStandalone && !$idHotel) { - $standaloneProduct = array_merge($type_value, $serviceProduct); - $standaloneServiceProducts[] = $standaloneProduct; - $formattedProduct = $serviceProduct; - } else { - continue; - } - - if (!isset($serviceProductsFormatted[$serviceProduct['id_product']])) { - $serviceProductsFormatted[$serviceProduct['id_product']] = array( - 'id_product' => $serviceProduct['id_product'], - 'name' => $serviceProduct['name'], - 'options' => array() - ); - } - $serviceProductsFormatted[$serviceProduct['id_product']]['options'][] = $formattedProduct; + } else if (Product::isSellableWithHotel($type_value['selling_preference_type'])) { + $hotelProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($id_order, $type_value['id_order_detail'], $type_value['product_id']); + foreach ($hotelProducts as $hotelProduct) { + $hotelServiceProducts[] = array_merge($type_value, $hotelProduct); + if (!isset($serviceProductsFormatted[$hotelProduct['id_product']])) { + $serviceProductsFormatted[$hotelProduct['id_product']] = array( + 'id_product' => $hotelProduct['id_product'], + 'name' => $hotelProduct['name'], + 'options' => array() + ); } + $hotelProduct['refund_denied'] = 0; + if (isset($hotelProduct['refund_info']) + && ($hotelProduct['refund_info']['refunded'] && !$hotelProduct['refund_info']['id_customization']) + ) { + $hotelProduct['refund_denied'] = 1; + } + $serviceProductsFormatted[$hotelProduct['id_product']]['options'][] = $hotelProduct; + } + } else if (Product::isSellableAsStandalone($type_value['selling_preference_type'])) { + $standaloneProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($id_order, $type_value['id_order_detail'], $type_value['product_id']); + foreach ($standaloneProducts as $standaloneProduct) { + $standaloneServiceProducts[] = array_merge($type_value, $standaloneProduct); + if (!isset($serviceProductsFormatted[$standaloneProduct['id_product']])) { + $serviceProductsFormatted[$standaloneProduct['id_product']] = array( + 'id_product' => $standaloneProduct['id_product'], + 'name' => $standaloneProduct['name'], + 'options' => array() + ); + } + $serviceProductsFormatted[$standaloneProduct['id_product']]['options'][] = $standaloneProduct; } } $roomTypes[$type_value['id_product']] = $type_value; diff --git a/js/admin.js b/js/admin.js index 48507c79a..06665a2df 100644 --- a/js/admin.js +++ b/js/admin.js @@ -1749,3 +1749,15 @@ function closeRecommendation() } }); } + +function applyPriceCalcMethodValue() +{ + var ci = $('#pcm_checkin').is(':checked') ? 1 : 0; + var co = $('#pcm_checkout').is(':checked') ? 2 : 0; + var ds = $('#pcm_duringstay').is(':checked') ? 4 : 0; + $('#price_calculation_method').val(ci + co + ds); +} +$(document).on('change','#pcm_checkin, #pcm_checkout, #pcm_duringstay', function() { + applyPriceCalcMethodValue(); +}); +applyPriceCalcMethodValue(); \ No newline at end of file diff --git a/js/admin/normal_products.js b/js/admin/normal_products.js index 9826b146f..6b283d882 100644 --- a/js/admin/normal_products.js +++ b/js/admin/normal_products.js @@ -565,34 +565,21 @@ product_tabs['Informations'] = new function(){ function applySellingPreferenceUIState() { - var sellingPreference = parseInt($('#selling_preference_type').val(), 10); - var showHotelTree = $.inArray(sellingPreference, [ - SELLING_PREFERENCE_HOTEL_STANDALONE, - SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE - ]) !== -1; - var showRoomTypeTree = $.inArray(sellingPreference, [ - 0, - SELLING_PREFERENCE_WITH_ROOM_TYPE, - SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE - ]) !== -1; - var showAutoAddToCart = $.inArray(sellingPreference, [ - 0, - SELLING_PREFERENCE_WITH_ROOM_TYPE, - SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE - ]) !== -1; + var withRoomType = $('#sp_with_room_type').is(':checked'); + var withHotel = $('#sp_with_hotel').is(':checked'); + var standalone = $('#sp_standalone').is(':checked'); + + // Bitmask: Room Type=1, Hotel=2, Standalone=4 + var sellingPreference = (withRoomType ? 1 : 0) + (withHotel ? 2 : 0) + (standalone ? 4 : 0); + $('#selling_preference_type').val(sellingPreference); + var $autoAddOff = $('#auto_add_to_cart_off'); var $autoAddCheckedInput; - toggleAssociationFieldNames('#associated_hotel_tree', showHotelTree); - toggleAssociationFieldNames('#associated_hotel_rooms_tree', showRoomTypeTree); + toggleAssociationFieldNames('#associated_hotel_tree', withHotel); + toggleAssociationFieldNames('#associated_hotel_rooms_tree', withRoomType); - if (showAutoAddToCart) { + if (withRoomType) { $('#auto_add_to_cart_container').show('fast'); $autoAddCheckedInput = $('input[name="auto_add_to_cart"]:checked'); if (!$autoAddCheckedInput.length) { @@ -609,12 +596,12 @@ product_tabs['Informations'] = new function(){ $('#product_options').show('fast'); } - $('#selling_preference_type').on('change',function(){ + $('#sp_with_room_type, #sp_with_hotel, #sp_standalone').on('change', function(){ setTimeout(function() { applySellingPreferenceUIState(); }, 0); }); - $('#selling_preference_type').trigger('change'); + applySellingPreferenceUIState(); $('#simple_product').attr('checked', true); $('input[name="type_product"]').on('click', function(e) diff --git a/modules/blockcart/ajax-cart.js b/modules/blockcart/ajax-cart.js index 85c34b47e..a7cdbe2e3 100644 --- a/modules/blockcart/ajax-cart.js +++ b/modules/blockcart/ajax-cart.js @@ -748,11 +748,12 @@ var ajaxCart = { //try to know if the current product is still in the new list var stayInTheCart = false; - var isHotelRow = (typeof ids[3] != 'undefined' && parseInt(ids[3], 10) > 0); + var isHotelRow = (typeof ids[3] != 'undefined' && parseInt(ids[3]) > 0); 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 (isHotelRow && (typeof jsonData.products[aProduct]['hotel_wise_data'] != 'undefined' && jsonData.products[aProduct]['hotel_wise_data'].length)) { + if (isHotelRow && jsonData.products[aProduct]['id'] == ids[0] + && (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] == this.id_hotel) { stayInTheCart = true; @@ -760,7 +761,20 @@ var ajaxCart = { }); } else { if (jsonData.products[aProduct]['id'] == ids[0] && (!ids[1] || jsonData.products[aProduct]['idCombination'] == ids[1])) { - stayInTheCart = true; + var productType = parseInt(jsonData.products[aProduct]['selling_preference_type']); + var isStandaloneRow = (typeof ids[3] == 'undefined' || parseInt(ids[3]) === 0); + + if (!isStandaloneRow) { + } else if ( + ajaxCart.isSellableAsStandalone(productType) + && (ajaxCart.isSellableWithHotel(productType) || ajaxCart.isSellableWithRoomType(productType)) + ) { + if (parseInt(jsonData.products[aProduct]['standalone_total_qty']) > 0) { + stayInTheCart = true; + } + } else { + stayInTheCart = true; + } // update the product customization display (when the product is still in the cart) ajaxCart.hideOldProductCustomizations(jsonData.products[aProduct], productDomId); } diff --git a/modules/hotelreservationsystem/classes/HotelCartBookingData.php b/modules/hotelreservationsystem/classes/HotelCartBookingData.php index 86b46ddd7..4a8565923 100644 --- a/modules/hotelreservationsystem/classes/HotelCartBookingData.php +++ b/modules/hotelreservationsystem/classes/HotelCartBookingData.php @@ -1027,6 +1027,25 @@ class HotelCartBookingData extends ObjectModel } } } + + // Check available stock: remove if cart quantity exceeds what is in stock. + if (!$toRemoveService) { + $availableQty = Product::getQuantity((int)$service['id_product']); + $totalQty = Cart::getProductQtyInCart((int)$service['id_cart'],(int)$service['id_product']); + if (!Product::isAvailableWhenOutOfStock(StockAvailable::outOfStock((int)$service['id_product'])) + && $availableQty !== false + && $availableQty < (int)$totalQty + ) { + $toRemoveService = 1; + } + } + + // Check max quantity: remove if cart quantity exceeds the product's configured maximum. + if (!$toRemoveService && $product->allow_multiple_quantity && (int)$product->max_quantity > 0) { + if ((int)$service['quantity'] > (int)$product->max_quantity) { + $toRemoveService = 1; + } + } } if ($toRemoveService) { diff --git a/modules/hotelreservationsystem/classes/HotelHelper.php b/modules/hotelreservationsystem/classes/HotelHelper.php index 709a9b23a..afc2a0735 100644 --- a/modules/hotelreservationsystem/classes/HotelHelper.php +++ b/modules/hotelreservationsystem/classes/HotelHelper.php @@ -2187,7 +2187,7 @@ class HotelHelper 'price' => '250', 'auto_add_to_cart' => 1, 'show_at_front' => 0, - 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_PER_BOOKING, + 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY, 'price_addition_type' => Product::PRICE_ADDITION_TYPE_INDEPENDENT, 'en' => array( 'name' => 'Internet Handling Charges', diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php index 9bac1f873..06bcd0079 100644 --- a/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php +++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php @@ -200,7 +200,12 @@ class RoomTypeServiceProduct extends ObjectModel $subCategory )) { $serviceProducts = Product::getProductsProperties($idLang, $serviceProducts); - foreach($serviceProducts as &$serviceProduct) { + foreach($serviceProducts as $key => &$serviceProduct) { + if (!$serviceProduct['allow_oosp'] && $serviceProduct['quantity'] <= 0) { + unset($serviceProducts[$key]); + continue; + } + $serviceProduct['price_tax_exc'] = Product::getServiceProductPrice( (int)$serviceProduct['id_product'], 0, diff --git a/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php b/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php index f7456863e..512e12b6b 100644 --- a/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php +++ b/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php @@ -95,7 +95,9 @@ class ServiceProductCartDetail extends ObjectModel $objHotelCartBookingData->date_from, $objHotelCartBookingData->date_to ); - $updateQty *= $numdays; + if($numdays){ + $updateQty *= $numdays; + } if ($objServiceProductCartDetail->delete()) { $objCart = new Cart($product['id_cart']); if (isset(Context::getContext()->controller->controller_type)) { @@ -269,7 +271,7 @@ class ServiceProductCartDetail extends ObjectModel 1, null, $product['htl_cart_booking_id'] - )/$numDays; + ) / max($numDays, 1); $priceTaxExcl = Product::getServiceProductPrice( $objProduct->id, $product['id_product_option'], @@ -284,7 +286,7 @@ class ServiceProductCartDetail extends ObjectModel 1, null, $product['htl_cart_booking_id'] - )/$numDays; + ) / max($numDays, 1); $optionDetails = false; if (ServiceProductOption::productHasOptions($product['id_product'])) { @@ -461,9 +463,11 @@ class ServiceProductCartDetail extends ObjectModel $objHotelCartBooking->date_from, $objHotelCartBooking->date_to ); - $quantity = $objServiceProductCartDetail->quantity * $numDays; + if($numDays){ + $quantity = $quantity * $numDays; + } } - + $objCart = new Cart($idCart); return $objCart->updateQty($quantity, $idProduct); } @@ -514,6 +518,16 @@ class ServiceProductCartDetail extends ObjectModel $updateQunatity = $objServiceProductCartDetail->delete(); } if ($updateQunatity) { + if (Validate::isLoadedObject($objHotelCartBooking = new HotelCartBookingData($product['id_hotel_cart_booking']))) { + $objProduct = new Product((int) $product['id_product']); + $numDays = Product::getPriceCalculationApplicableDays( + $objProduct->price_calculation_method, + $objHotelCartBooking->date_from, + $objHotelCartBooking->date_to + ); + $removedQuantity = $removedQuantity * $numDays; + } + $objCart = new Cart($idCart); if (isset(Context::getContext()->controller->controller_type)) { $controllerType = Context::getContext()->controller->controller_type; diff --git a/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl b/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl index d8cadf9e9..3a181b149 100644 --- a/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl @@ -372,7 +372,7 @@
diff --git a/modules/qlostatsserviceproducts/qlostatsserviceproducts.php b/modules/qlostatsserviceproducts/qlostatsserviceproducts.php index fd72eb7e3..684cf15f9 100644 --- a/modules/qlostatsserviceproducts/qlostatsserviceproducts.php +++ b/modules/qlostatsserviceproducts/qlostatsserviceproducts.php @@ -179,24 +179,25 @@ class QloStatsServiceProducts extends ModuleGrid public function setQueryForServices($dateBetween) { + $numNightsSql = 'IFNULL(DATEDIFF(hbd.`date_to`, hbd.`date_from`), 0)'; + $applicableDaysSql = 'CASE + WHEN spod.`id_htl_booking_detail` IS NULL OR spod.`id_htl_booking_detail` = 0 THEN 1 + WHEN od.`product_price_calculation_method` IN ('.(int)Product::PRICE_CALCULATION_METHOD_ONLY_CHECKIN_DAY.', '.(int)Product::PRICE_CALCULATION_METHOD_ONLY_CHECKOUT_DAY.') THEN 1 + WHEN od.`product_price_calculation_method` = '.(int)Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY.' THEN GREATEST('.$numNightsSql.' - 1, 1) + WHEN od.`product_price_calculation_method` = '.(int)Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY.' THEN 2 + WHEN od.`product_price_calculation_method` IN ('.(int)Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURINGSTAY.', '.(int)Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURINGSTAY.') THEN GREATEST('.$numNightsSql.', 1) + WHEN od.`product_price_calculation_method` = '.(int)Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY.' THEN GREATEST('.$numNightsSql.' + 1, 1) + ELSE GREATEST('.$numNightsSql.', 1) + END'; + $this->query = '(SELECT od.`product_name` as `display_name`, p.`active`, od.`product_auto_add` as auto_add_to_cart, od.`product_price_addition_type` as price_addition_type, ROUND(IFNULL(SUM(spod.`total_price_tax_excl` / o.`conversion_rate`), 0), 2) / SUM( - IF(od.`product_price_calculation_method` = '.(int)Product::PRICE_CALCULATION_METHOD_PER_DAY.', - (IF(spod.`id_htl_booking_detail`, - DATEDIFF(hbd.`date_to`, hbd.`date_from`), - 1)) * spod.`quantity`, - spod.`quantity` - ) + ('.$applicableDaysSql.') * spod.`quantity` ) AS avgPriceSold, IFNULL(SUM( - IF(od.`product_price_calculation_method` = '.(int)Product::PRICE_CALCULATION_METHOD_PER_DAY.', - (IF(spod.`id_htl_booking_detail`, - DATEDIFF(hbd.`date_to`, hbd.`date_from`), - 1)) * spod.`quantity`, - spod.`quantity` - ) + ('.$applicableDaysSql.') * spod.`quantity` ), 0) AS totalQuantitySold, ROUND(IFNULL(SUM(spod.`total_price_tax_excl` / o.`conversion_rate`), 0), 2) AS totalPriceSold FROM '._DB_PREFIX_.'service_product_order_detail spod diff --git a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl index 5a3db8aaa..b22722e4f 100644 --- a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl +++ b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl @@ -82,7 +82,7 @@

- {if isset($selected_adv_option) && isset($demand['adv_option'][$selected_adv_option]['price'])}{convertPrice price = $demand['adv_option'][$selected_adv_option]['price']|escape:'html':'UTF-8'}{else}{convertPrice price = $demand['price']|escape:'html':'UTF-8'}{/if}{if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY}{l s='/Night'}{/if} + {if isset($selected_adv_option) && isset($demand['adv_option'][$selected_adv_option]['price'])}{convertPrice price = $demand['adv_option'][$selected_adv_option]['price']|escape:'html':'UTF-8'}{else}{convertPrice price = $demand['price']|escape:'html':'UTF-8'}{/if}{if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY}{l s='/Day'}{/if}

@@ -156,7 +156,7 @@ $product.price_calculation_method, $cartRoom.date_from|default:'', $cartRoom.date_to|default:'' - ) > 1}{l s='/Night'}{/if} + ) > 1}{l s='/Day'}{/if} {/if} diff --git a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl index 5a8896426..fa04edfea 100644 --- a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl +++ b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl @@ -59,7 +59,7 @@ $service_product.date_from|default:$date_from|default:'', $service_product.date_to|default:$date_to|default:'' ) > 1} - {l s='/Night'} + {l s='/Day'} {/if} {/block} {if $service_product.allow_multiple_quantity && $service_product.available_for_order && $service_product.max_quantity > 0} 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 85c34b47e..a69ecd93f 100644 --- a/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js +++ b/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js @@ -748,11 +748,12 @@ var ajaxCart = { //try to know if the current product is still in the new list var stayInTheCart = false; - var isHotelRow = (typeof ids[3] != 'undefined' && parseInt(ids[3], 10) > 0); + var isHotelRow = (typeof ids[3] != 'undefined' && parseInt(ids[3]) > 0); 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 (isHotelRow && (typeof jsonData.products[aProduct]['hotel_wise_data'] != 'undefined' && jsonData.products[aProduct]['hotel_wise_data'].length)) { + if (isHotelRow && jsonData.products[aProduct]['id'] == ids[0] + && (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] == this.id_hotel) { stayInTheCart = true; @@ -760,7 +761,20 @@ var ajaxCart = { }); } else { if (jsonData.products[aProduct]['id'] == ids[0] && (!ids[1] || jsonData.products[aProduct]['idCombination'] == ids[1])) { - stayInTheCart = true; + var productType = parseInt(jsonData.products[aProduct]['selling_preference_type']); + var isStandaloneRow = (typeof ids[3] == 'undefined' || parseInt(ids[3]) === 0); + + if (!isStandaloneRow) { + } else if ( + ajaxCart.isSellableAsStandalone(productType) + && (ajaxCart.isSellableWithHotel(productType) || ajaxCart.isSellableWithRoomType(productType)) + ) { + if (parseInt(jsonData.products[aProduct]['standalone_total_qty']) > 0) { + stayInTheCart = true; + } + } else { + stayInTheCart = true; + } // update the product customization display (when the product is still in the cart) ajaxCart.hideOldProductCustomizations(jsonData.products[aProduct], productDomId); } @@ -945,7 +959,7 @@ var ajaxCart = { if (product.booking_product) { content += formatCurrency(parseFloat(product.bookingData.total_room_type_amount), currency_format, currency_sign, currency_blank); - } else if (typeof(hotel_wise_data) != 'undefined') { + } else if (typeof(hotel_wise_data) != 'undefined' && ajaxCart.isSellableWithHotel(product.selling_preference_type)) { content += formatCurrency(parseFloat(hotel_wise_data.amount), currency_format, currency_sign, currency_blank); } else { content += formatCurrency(parseFloat(product.amount), currency_format, currency_sign, currency_blank); diff --git a/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl b/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl index a45968365..182945dfe 100644 --- a/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl +++ b/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl @@ -64,7 +64,7 @@ {foreach from=$products key=data_k item='product' name='myLoop'} {* only show products that are booking or global without room *} {if $product.booking_product || Product::isSellableAsStandalone($product.selling_preference_type) || Product::isSellableWithHotel($product.selling_preference_type)} - {if isset($product.hotel_wise_data) && $product.hotel_wise_data} + {if Product::isSellableWithHotel($product.selling_preference_type) && isset($product.hotel_wise_data) && $product.hotel_wise_data} {foreach $product.hotel_wise_data as $hotel_wise_data} {include file="./cartrow.tpl" hotel_wise_data=$hotel_wise_data} {/foreach} @@ -144,7 +144,7 @@ {/if} {/block} {block name='blockcart_shopping_cart_total_convenience_fee'} - {if isset($total_convenience_fee)} + {if isset($total_convenience_fee) && $total_convenience_fee}
{convertPrice price=$total_convenience_fee} {l s='Convenience Fees' mod='blockcart'} @@ -326,7 +326,7 @@
--> {block name='blockcart_layer_cart_total_convenience_fee'} - {if isset($total_convenience_fee)} + {if isset($total_convenience_fee) && $total_convenience_fee}
{l s='Convenience Fees' mod='blockcart'} diff --git a/themes/hotel-reservation-theme/order-confirmation.tpl b/themes/hotel-reservation-theme/order-confirmation.tpl index e8cc450cc..2297d556b 100644 --- a/themes/hotel-reservation-theme/order-confirmation.tpl +++ b/themes/hotel-reservation-theme/order-confirmation.tpl @@ -254,9 +254,9 @@
{l s='Unit Price'}
{if $group_use_tax} - {displayWtPriceWithCurrency price=$product.unit_price_tax_incl currency=$currency} + {displayWtPriceWithCurrency price=$product.unit_price_tax_incl currency=$objOrderCurrency} {else} - {displayWtPriceWithCurrency price=$product.unit_price_tax_excl currency=$currency} + {displayWtPriceWithCurrency price=$product.unit_price_tax_excl currency=$objOrderCurrency} {/if}
@@ -272,9 +272,9 @@
{l s='Total Pricing'}
{if $group_use_tax} - {displayWtPriceWithCurrency price=$product.total_price_tax_incl currency=$currency} + {displayWtPriceWithCurrency price=$product.total_price_tax_incl currency=$objOrderCurrency} {else} - {displayWtPriceWithCurrency price=$product.total_price_tax_excl currency=$currency} + {displayWtPriceWithCurrency price=$product.total_price_tax_excl currency=$objOrderCurrency} {/if}
@@ -328,9 +328,9 @@
{l s='Unit Price'}
{if $group_use_tax} - {displayWtPriceWithCurrency price=$product.unit_price_tax_incl currency=$currency} + {displayWtPriceWithCurrency price=$product.unit_price_tax_incl currency=$objOrderCurrency} {else} - {displayWtPriceWithCurrency price=$product.unit_price_tax_excl currency=$currency} + {displayWtPriceWithCurrency price=$product.unit_price_tax_excl currency=$objOrderCurrency} {/if}
@@ -346,9 +346,9 @@
{l s='Total Pricing'}
{if $group_use_tax} - {displayWtPriceWithCurrency price=$product.total_price_tax_incl currency=$currency} + {displayWtPriceWithCurrency price=$product.total_price_tax_incl currency=$objOrderCurrency} {else} - {displayWtPriceWithCurrency price=$product.total_price_tax_excl currency=$currency} + {displayWtPriceWithCurrency price=$product.total_price_tax_excl currency=$objOrderCurrency} {/if}
diff --git a/themes/hotel-reservation-theme/order-detail.tpl b/themes/hotel-reservation-theme/order-detail.tpl index d1682db6a..c0bc6432d 100644 --- a/themes/hotel-reservation-theme/order-detail.tpl +++ b/themes/hotel-reservation-theme/order-detail.tpl @@ -1133,7 +1133,7 @@ {addJsDefL name=pending_state_msg}{l s='Pending...' js=1}{/addJsDefL} {addJsDefL name=mail_sending_err}{l s='Some error occurred while sending mail to the customer' js=1}{/addJsDefL} {addJsDefL name=refund_request_sending_error}{l s='Some error occurred while processing request for booking cancellation.' js=1}{/addJsDefL} - {addJsDefL name=no_bookings_selected}{l s='Please select at least one room to proceed for cancellation.' js=1}{/addJsDefL} + {addJsDefL name=no_bookings_selected}{l s='Please select at least one room or service to proceed for cancellation.' js=1}{/addJsDefL} {addJsDefL name=refund_request_success_txt}{l s='Request for booking cancellation is successffully created.' js=1}{/addJsDefL} {addJsDefL name=order_message_choose_txt}{l s='-- Choose --' js=1}{/addJsDefL} {addJsDefL name=order_message_success_txt}{l s='Order message sent successfully.' js=1}{/addJsDefL} diff --git a/themes/hotel-reservation-theme/product.tpl b/themes/hotel-reservation-theme/product.tpl index 9492fbc86..70f6deb30 100644 --- a/themes/hotel-reservation-theme/product.tpl +++ b/themes/hotel-reservation-theme/product.tpl @@ -455,7 +455,7 @@ {/if}
-

{$demand['name']|escape:'html':'UTF-8'} {if $product->show_price && !isset($restricted_country_mode) && !$PS_CATALOG_MODE}{convertPrice price = $demand['price']}{if $demand['price_calc_method'] == $WK_PRICE_CALC_METHOD_EACH_DAY}{l s='/Night'}{/if}{/if}

+

{$demand['name']|escape:'html':'UTF-8'} {if $product->show_price && !isset($restricted_country_mode) && !$PS_CATALOG_MODE}{convertPrice price = $demand['price']}{if $demand['price_calc_method'] == $WK_PRICE_CALC_METHOD_EACH_DAY}{l s='/day'}{/if}{/if}

{if isset($demand['adv_option']) && $demand['adv_option']} - {foreach $associated_hotels as $hotel} - - {/foreach} - + +
+ +
+
+ +
{/if} {/block} + {block name='booking_form_associated_hotels'} +
+ {if isset($associated_hotels) && $associated_hotels} +
+ + +
+ {/if} +
+ {/block} {block name='booking_form_product_option'} {if isset($product_option) && $product_option} 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 a69ecd93f..51978e8fe 100644 --- a/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js +++ b/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js @@ -201,7 +201,7 @@ var ajaxCart = { var date_from = $('#room_check_in').val(); var date_to = $('#room_check_out').val(); - var id_hotel = $('#service_id_hotel').length ? $('#service_id_hotel').val() : 0; + var id_hotel = ($('input[name="buying_option"]').length && $('input[name="buying_option"]:checked').val() == '2') ? 0 : ($('#service_id_hotel').length ? $('#service_id_hotel').val() : 0); var occupancy = getBookingOccupancyDetails($(this).closest('.booking_room_fields'), parseInt(booking_product)); if (occupancy) { diff --git a/themes/hotel-reservation-theme/js/product.js b/themes/hotel-reservation-theme/js/product.js index b0771177c..4c375b794 100644 --- a/themes/hotel-reservation-theme/js/product.js +++ b/themes/hotel-reservation-theme/js/product.js @@ -1590,4 +1590,12 @@ function getBookingOccupancy() } return occupancy; -} \ No newline at end of file +} + +$(document).on('change', 'input[name="buying_option"]', function() { + if ($(this).val() == '2') { + $('#hotel_selection_block').hide(); + } else { + $('#hotel_selection_block').show(); + } +}); \ No newline at end of file From 3acacf95f9525c90e80ba6798524105327b5482b Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Tue, 26 May 2026 17:53:50 +0530 Subject: [PATCH 12/34] Added: price calculation info tooltip on service products list --- admin/themes/default/css/admin-tooltip.css | 79 +++++++++++++++++++ admin/themes/default/js/admin-theme.js | 45 +++++++++++ .../normal_products/selected_option.tpl | 65 --------------- .../template/controllers/orders/form.tpl | 27 +++++++ .../_add_order_extra_services_tab_content.tpl | 5 +- ..._services_service_products_tab_content.tpl | 10 ++- .../_partials/_price-calculation-info.tpl | 43 ++++++++++ classes/Product.php | 4 +- .../admin/AdminNormalProductsController.php | 5 +- controllers/admin/AdminOrdersController.php | 2 + controllers/front/OrderOpcController.php | 1 + controllers/front/ProductController.php | 1 + js/admin/normal_products.js | 24 ++---- js/admin/orders.js | 19 ++++- .../_partials/cart_booking_demands.tpl | 3 +- .../_partials/order-extra-services.tpl | 1 + .../_partials/price-calculation-info.tpl | 43 ++++++++++ .../_partials/service-products-list-row.tpl | 1 + themes/hotel-reservation-theme/css/global.css | 34 ++++++++ themes/hotel-reservation-theme/js/global.js | 38 +++++++++ .../js/order-confirmation.js | 1 + .../js/order-detail.js | 1 + .../hotel-reservation-theme/js/order-opc.js | 1 + themes/hotel-reservation-theme/js/product.js | 3 +- 24 files changed, 363 insertions(+), 93 deletions(-) create mode 100644 admin/themes/default/css/admin-tooltip.css create mode 100644 admin/themes/default/template/controllers/orders/modals/_partials/_price-calculation-info.tpl create mode 100644 themes/hotel-reservation-theme/_partials/price-calculation-info.tpl diff --git a/admin/themes/default/css/admin-tooltip.css b/admin/themes/default/css/admin-tooltip.css new file mode 100644 index 000000000..c4d618cb3 --- /dev/null +++ b/admin/themes/default/css/admin-tooltip.css @@ -0,0 +1,79 @@ +/* +* NOTICE OF LICENSE +* +* This source file is subject to the Open Software License version 3.0 +* that is bundled with this package in the file LICENSE.md +* It is also available through the world-wide-web at this URL: +* https://opensource.org/license/osl-3-0-php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to support@qloapps.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade this module to a newer +* versions in the future. If you wish to customize this module for your needs +* please refer to https://store.webkul.com/customisation-guidelines for more information. +* +* @author Webkul IN +* @copyright Since 2010 Webkul +* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0 +*/ + +/* Trigger element styles */ +.selected-option-info, +.price-calculation-info { + cursor: pointer; +} + +.price-calculation-info { + display: inline-block; + vertical-align: middle; + margin-left: 4px; +} + +.selected-option-info .icon-info-sign, +.price-calculation-info .icon-info-sign { + color: #00aff0; + font-size: 16px; +} + +/* Unified tooltip bubble */ +.ui-tooltip.admin-info-tooltip { + background: #ffffff; + border: 1px solid #ddd; + box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); + color: #333; + padding: 8px 12px; + font-size: 13px; +} + +.ui-tooltip.admin-info-tooltip ul { + margin: 0; + padding: 0 0 0 16px; + list-style: disc; +} + +.ui-tooltip.admin-info-tooltip ul li { + padding: 2px 0; +} + +.ui-tooltip.admin-info-tooltip .price-info-tooltip-cont { + min-width: 160px; +} + +.ui-tooltip.admin-info-tooltip .applied-on-label { + margin: 0 0 6px; + font-weight: 600; + font-size: 13px; +} + +.ui-tooltip.admin-info-tooltip .applied-on-days { + margin: 0; + padding-left: 16px; + font-size: 13px; +} + +.ui-tooltip.admin-info-tooltip .applied-on-days li { + padding: 2px 0; +} diff --git a/admin/themes/default/js/admin-theme.js b/admin/themes/default/js/admin-theme.js index 1aa61350d..0fdc86b2e 100644 --- a/admin/themes/default/js/admin-theme.js +++ b/admin/themes/default/js/admin-theme.js @@ -479,3 +479,48 @@ $(document).ready(function() { $(this).prop('selected', false); }); }); //end dom ready + + +function initAdminTooltip(config) { + var $elements = $(config.selector); + if (!$elements.length) { + return; + } + $elements.each(function () { + if (config.skipIfInitialized && $(this).data('ui-tooltip')) { + return; + } + $(this).tooltip({ + content: config.getContent, + items: config.items, + trigger: 'hover', + tooltipClass: config.tooltipClass, + open: function (event, ui) { + if (typeof event.originalEvent === 'undefined') { + return false; + } + var $id = $(ui.tooltip).attr('id'); + if ($('div.ui-tooltip').not('#' + $id).length) { + return false; + } + }, + close: function (event, ui) { + ui.tooltip.hover( + function () { $(this).stop(true).fadeTo(400, 1); }, + function () { $(this).fadeOut(400, function () { $(this).remove(); }); } + ); + } + }); + }); +} + +$(document).ready(function () { + initAdminTooltip({ + selector: '.selected-option-info', + items: '.selected-option-info', + tooltipClass: 'admin-info-tooltip', + getContent: function () { + return $(this).data('options'); + } + }); +}); \ No newline at end of file diff --git a/admin/themes/default/template/controllers/normal_products/selected_option.tpl b/admin/themes/default/template/controllers/normal_products/selected_option.tpl index fab919780..24156a9e1 100644 --- a/admin/themes/default/template/controllers/normal_products/selected_option.tpl +++ b/admin/themes/default/template/controllers/normal_products/selected_option.tpl @@ -20,34 +20,6 @@ * @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0 *} -{if empty($selected_option_css_initialized)} - {assign var='selected_option_css_initialized' value=true scope='global'} - -{/if} {capture name='options_list'}
    @@ -59,40 +31,3 @@ {$selected_options|@count} Selected - -{if empty($selected_option_js_initialized)} - {assign var='selected_option_js_initialized' value=true scope='global'} - -{/if} diff --git a/admin/themes/default/template/controllers/orders/form.tpl b/admin/themes/default/template/controllers/orders/form.tpl index dda7d6aa5..3d6f19103 100644 --- a/admin/themes/default/template/controllers/orders/form.tpl +++ b/admin/themes/default/template/controllers/orders/form.tpl @@ -1595,6 +1595,15 @@ }, complete: function() { $(".loading_overlay").hide(); + initAdminTooltip({ + selector: '.price-calculation-info', + items: 'span', + tooltipClass: 'admin-info-tooltip', + skipIfInitialized: true, + getContent: function () { + return $(this).siblings('.price-calculation-info-container').html(); + } + }); } }); }); @@ -1815,6 +1824,15 @@ }, complete: function() { $(".loading_overlay").hide(); + initAdminTooltip({ + selector: '.price-calculation-info', + items: 'span', + tooltipClass: 'admin-info-tooltip', + skipIfInitialized: true, + getContent: function () { + return $(this).siblings('.price-calculation-info-container').html(); + } + }); } }); }); @@ -1865,6 +1883,15 @@ }, complete: function() { $(".loading_overlay").hide(); + initAdminTooltip({ + selector: '.price-calculation-info', + items: 'span', + tooltipClass: 'admin-info-tooltip', + skipIfInitialized: true, + getContent: function () { + return $(this).siblings('.price-calculation-info-container').html(); + } + }); } }); }); diff --git a/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl b/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl index d56daffe8..da29873a8 100644 --- a/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl +++ b/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl @@ -61,7 +61,10 @@
-

{$product['name']|escape:'html':'UTF-8'}

+
+ {$product['name']|escape:'html':'UTF-8'} + {include file='controllers/orders/modals/_partials/_price-calculation-info.tpl' pcm=$product['price_calculation_method']|default:0} +
{if $product['auto_add_to_cart'] && $product['price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT} diff --git a/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl b/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl index d8d3ef96d..b322c7dde 100644 --- a/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl +++ b/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl @@ -53,7 +53,9 @@ {foreach $additionalServices['additional_services'] as $service}
-
{$service['name']|escape:'html':'UTF-8'}
+
+ {$service['name']|escape:'html':'UTF-8'} +
@@ -134,6 +136,7 @@ {$product['name']|escape:'html':'UTF-8'} + {include file='controllers/orders/modals/_partials/_price-calculation-info.tpl' pcm=$product['price_calculation_method']|default:0} {if $product['auto_add_to_cart'] && $product['price_addition_type'] == Product::PRICE_ADDITION_TYPE_WITH_ROOM} @@ -291,7 +294,10 @@ {$service['id_product']|escape:'html':'UTF-8'}{if !$service['product_deleted']} {/if} {$service['name']|escape:'html':'UTF-8'} + {$service['name']|escape:'html':'UTF-8'} + {include file='controllers/orders/modals/_partials/_price-calculation-info.tpl' pcm=$service.price_calculation_method|default:0} + {if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT} {l s='Convenience fee'} diff --git a/admin/themes/default/template/controllers/orders/modals/_partials/_price-calculation-info.tpl b/admin/themes/default/template/controllers/orders/modals/_partials/_price-calculation-info.tpl new file mode 100644 index 000000000..00ad669f5 --- /dev/null +++ b/admin/themes/default/template/controllers/orders/modals/_partials/_price-calculation-info.tpl @@ -0,0 +1,43 @@ +{* +* NOTICE OF LICENSE +* +* This source file is subject to the Open Software License version 3.0 +* that is bundled with this package in the file LICENSE.md +* It is also available through the world-wide-web at this URL: +* https://opensource.org/license/osl-3-0-php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to support@qloapps.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade this module to a newer +* versions in the future. If you wish to customize this module for your needs +* please refer to https://store.webkul.com/customisation-guidelines for more information. +* +* @author Webkul IN +* @copyright Since 2010 Webkul +* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0 +*} + +{* Required param: pcm — price_calculation_method integer value *} + + + + + diff --git a/classes/Product.php b/classes/Product.php index f88ec4917..3267ff979 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -562,8 +562,8 @@ class ProductCore extends ObjectModel const SELLING_PREFERENCE_HOTEL_STANDALONE = 2; // Product to be sold Standalone with Hotels const SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE = 3; // Product to be sold Standalone with Hotels and with Room types also const SELLING_PREFERENCE_STANDALONE = 4; // Product to be sold standalone - const SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE = 5; // Product to be sold standalone with Hotels and with Room types also - const SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE = 6; // Product to be sold standalone and with Room types also + const SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE = 5; // Product to be sold standalone and with Room types also + const SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE = 6; // Product to be sold standalone with Hotels and with Room types also const SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE = 7; // Product to be sold standalone with Hotels and with Room types also and standalone const PRICE_ADDITION_TYPE_WITH_ROOM = 1; diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index 7bea0215f..0c3986722 100644 --- a/controllers/admin/AdminNormalProductsController.php +++ b/controllers/admin/AdminNormalProductsController.php @@ -487,7 +487,7 @@ class AdminNormalProductsControllerCore extends AdminController .'template')) { $bo_theme = 'default'; } - $this->addJqueryUI('ui.tooltip', 'base', true); + $this->addJs(__PS_BASE_URI__.$this->admin_webpath.'/themes/'.$bo_theme.'/js/jquery.iframe-transport.js'); $this->addJs(__PS_BASE_URI__.$this->admin_webpath.'/themes/'.$bo_theme.'/js/jquery.fileupload.js'); $this->addJs(__PS_BASE_URI__.$this->admin_webpath.'/themes/'.$bo_theme.'/js/jquery.fileupload-process.js'); @@ -1542,6 +1542,9 @@ class AdminNormalProductsControllerCore extends AdminController _PS_JS_DIR_.'jquery/plugins/timepicker/jquery-ui-timepicker-addon.css', _PS_CSS_DIR_.'ps-hotel-reservation.css', )); + }else { + $this->addCSS(__PS_BASE_URI__.$this->admin_webpath.'/themes/default/css/admin-tooltip.css'); + $this->addJqueryUI('ui.tooltip', 'base', true); } } diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 7dcae4db2..ba8a1e481 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -1334,6 +1334,8 @@ class AdminOrdersControllerCore extends AdminController $this->addJqueryUI('ui.datepicker'); $this->addJS(_PS_JS_DIR_.'vendor/d3.v3.min.js'); + $this->addCSS(__PS_BASE_URI__.$this->admin_webpath.'/themes/default/css/admin-tooltip.css'); + $this->addJqueryUI(array('ui.tooltip'), 'base', true); if ($this->display == 'view') { if ($this->loadObject()) { diff --git a/controllers/front/OrderOpcController.php b/controllers/front/OrderOpcController.php index d1814c445..1628eb376 100644 --- a/controllers/front/OrderOpcController.php +++ b/controllers/front/OrderOpcController.php @@ -416,6 +416,7 @@ class OrderOpcControllerCore extends ParentOrderController } else { $this->addJS(_THEME_MOBILE_JS_DIR_.'opc.js'); } + $this->addJqueryUI(array('ui.tooltip'), 'base', true); $this->addJS(array( _THEME_JS_DIR_.'tools/statesManagement.js', diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index 2bd349a78..22e74f24b 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -40,6 +40,7 @@ class ProductControllerCore extends FrontController if (count($this->errors)) { return; } + $this->addJqueryUI(array('ui.tooltip'), 'base', true); if (!$this->useMobileTheme()) { $this->addCSS(_THEME_CSS_DIR_.'product.css'); diff --git a/js/admin/normal_products.js b/js/admin/normal_products.js index 3047cf9a0..e42f286de 100644 --- a/js/admin/normal_products.js +++ b/js/admin/normal_products.js @@ -568,26 +568,12 @@ product_tabs['Informations'] = new function(){ var withRoomType = $('#sp_with_room_type').is(':checked'); var withHotel = $('#sp_with_hotel').is(':checked'); var standalone = $('#sp_standalone').is(':checked'); + const sellingPreference = + (withRoomType ? SELLING_PREFERENCE_WITH_ROOM_TYPE : 0) | + (withHotel ? SELLING_PREFERENCE_HOTEL_STANDALONE : 0) | + (standalone ? SELLING_PREFERENCE_STANDALONE : 0); - var sellingPreference; - if (withRoomType && withHotel && standalone) { - sellingPreference = 7; // HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE - } else if (withHotel && standalone) { - sellingPreference = 5; // HOTEL_STANDALONE_AND_WITH_STANDALONE - } else if (withRoomType && standalone) { - sellingPreference = 6; // STANDALONE_AND_WITH_ROOM_TYPE - } else if (withRoomType && withHotel) { - sellingPreference = 3; // HOTEL_STANDALONE_AND_WITH_ROOM_TYPE - } else if (standalone) { - sellingPreference = 4; // STANDALONE - } else if (withHotel) { - sellingPreference = 2; // HOTEL_STANDALONE - } else if (withRoomType) { - sellingPreference = 1; // WITH_ROOM_TYPE - } else { - sellingPreference = 0; - } - $('#selling_preference_type').val(sellingPreference); + $('#selling_preference_type').val(sellingPreference); var $autoAddOff = $('#auto_add_to_cart_off'); var $autoAddCheckedInput; diff --git a/js/admin/orders.js b/js/admin/orders.js index 9d88bb44a..2eb349cf8 100644 --- a/js/admin/orders.js +++ b/js/admin/orders.js @@ -1410,6 +1410,15 @@ $(document).ready(function() { }, complete: function() { $(".loading_overlay").hide(); + initAdminTooltip({ + selector: '.price-calculation-info', + items: 'span', + tooltipClass: 'admin-info-tooltip', + skipIfInitialized: true, + getContent: function () { + return $(this).siblings('.price-calculation-info-container').html(); + } + }); } }); }); @@ -2481,7 +2490,15 @@ const EditRoomBookingModal = { // initialize datepickers EditRoomBookingModal.initDatePickers(); - + initAdminTooltip({ + selector: '.price-calculation-info', + items: 'span', + tooltipClass: 'admin-info-tooltip', + skipIfInitialized: true, + getContent: function () { + return $(this).siblings('.price-calculation-info-container').html(); + } + }); $('#edit_product .extra-services-container #id_htl_booking').val(jsonProductLineData.id); $('#edit-room-booking-modal').modal('show'); } else { diff --git a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl index b22722e4f..7f218e0c8 100644 --- a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl +++ b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl @@ -134,7 +134,8 @@ {/if}
-

{$product['name']|escape:'html':'UTF-8'}

+ {$product['name']|escape:'html':'UTF-8'} + {include file='_partials/price-calculation-info.tpl' pcm=$product.price_calculation_method|default:0} {if $product.allow_multiple_quantity}
diff --git a/themes/hotel-reservation-theme/_partials/order-extra-services.tpl b/themes/hotel-reservation-theme/_partials/order-extra-services.tpl index 095cfc644..903ba40c8 100644 --- a/themes/hotel-reservation-theme/_partials/order-extra-services.tpl +++ b/themes/hotel-reservation-theme/_partials/order-extra-services.tpl @@ -58,6 +58,7 @@ {if $additionalService['allow_multiple_quantity']} {l s='(Quantity: %s)' sprintf=[$additionalService['quantity']|string_format:'%02d']} {/if} + {include file='_partials/price-calculation-info.tpl' pcm=$additionalService.price_calculation_method|default:0}
diff --git a/themes/hotel-reservation-theme/_partials/price-calculation-info.tpl b/themes/hotel-reservation-theme/_partials/price-calculation-info.tpl new file mode 100644 index 000000000..af5f05850 --- /dev/null +++ b/themes/hotel-reservation-theme/_partials/price-calculation-info.tpl @@ -0,0 +1,43 @@ +{** +* NOTICE OF LICENSE +* +* This source file is subject to the Open Software License version 3.0 +* that is bundled with this package in the file LICENSE.md +* It is also available through the world-wide-web at this URL: +* https://opensource.org/license/osl-3-0-php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to support@qloapps.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade this module to a newer +* versions in the future. If you wish to customize this module for your needs +* please refer to https://store.webkul.com/customisation-guidelines for more information. +* +* @author Webkul IN +* @copyright Since 2010 Webkul +* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0 +*} + +{* Required param: pcm — price_calculation_method integer value *} + + + + + diff --git a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl index fa04edfea..8df8fe516 100644 --- a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl +++ b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl @@ -38,6 +38,7 @@ {block name='service_product_name'}
{$service_product['name']} + {include file='_partials/price-calculation-info.tpl' pcm=$service_product.price_calculation_method|default:0}
{/block} {block name='service_product_description'} diff --git a/themes/hotel-reservation-theme/css/global.css b/themes/hotel-reservation-theme/css/global.css index 7fb667b55..5f279fe45 100644 --- a/themes/hotel-reservation-theme/css/global.css +++ b/themes/hotel-reservation-theme/css/global.css @@ -9187,3 +9187,37 @@ div a.our_properties_link{ color: #fff; font-size: 17px; font-weight: 400;} + +/* price calculation info tooltip */ +.price-calculation-info { + cursor: pointer; + display: inline-block; + vertical-align: middle; + margin-left: 4px; +} +.ui-tooltip.price-tootip { + box-shadow: 0 2px 6px 0 rgb(0 0 0 / 20%); + background: #FFFFFF; + border: unset; + color: #333; + padding: 9px 15px; +} +.ui-tooltip.price-tootip .price-info-tooltip-cont { + min-width: 160px; +} +.ui-tooltip.price-tootip .applied-on-label { + margin: 0 0 6px; + font-weight: 600; + font-size: 13px; +} +.ui-tooltip.price-tootip .applied-on-days { + margin: 0; + padding-left: 16px; + font-size: 13px; +} +.ui-tooltip.price-tootip .applied-on-days li { + padding: 2px 0; +} +.price-info-tooltip-cont ul li{ + list-style: disc;; +} diff --git a/themes/hotel-reservation-theme/js/global.js b/themes/hotel-reservation-theme/js/global.js index ff00f02c0..b842d5b47 100644 --- a/themes/hotel-reservation-theme/js/global.js +++ b/themes/hotel-reservation-theme/js/global.js @@ -457,3 +457,41 @@ window.addEventListener('online', function () { window.addEventListener('offline', function () { onlineFlag = false; }); + +function initPriceCalculationTooltip() { + if ($('.price-calculation-info').length) { + $('.price-calculation-info').each(function () { + if ($(this).hasClass('ui-tooltip-content')) { + return; + } + $(this).tooltip({ + content: $(this).siblings('.price-calculation-info-container').html(), + items: 'span', + trigger: 'hover', + tooltipClass: 'price-tootip', + open: function (event, ui) { + if (typeof (event.originalEvent) === 'undefined') { + return false; + } + var $id = $(ui.tooltip).attr('id'); + if ($('div.ui-tooltip').not('#' + $id).length) { + return false; + } + }, + close: function (event, ui) { + ui.tooltip.hover(function () { + $(this).stop(true).fadeTo(400, 1); + }, function () { + $(this).fadeOut('400', function () { + $(this).remove(); + }); + }); + } + }); + }); + } +} + +$(document).ready(function () { + initPriceCalculationTooltip(); +}); diff --git a/themes/hotel-reservation-theme/js/order-confirmation.js b/themes/hotel-reservation-theme/js/order-confirmation.js index 615bee6ff..d9b645df8 100644 --- a/themes/hotel-reservation-theme/js/order-confirmation.js +++ b/themes/hotel-reservation-theme/js/order-confirmation.js @@ -49,6 +49,7 @@ $(document).ready(function(){ if (result.extra_demands) { $('#rooms_extra_services').html(''); $('#rooms_extra_services').append(result.extra_demands); + initPriceCalculationTooltip(); } $.fancybox({ href: "#rooms_extra_services", diff --git a/themes/hotel-reservation-theme/js/order-detail.js b/themes/hotel-reservation-theme/js/order-detail.js index 800440304..a0e1a9ac7 100644 --- a/themes/hotel-reservation-theme/js/order-detail.js +++ b/themes/hotel-reservation-theme/js/order-detail.js @@ -362,6 +362,7 @@ $(document).on('click', '.btn-view-extra-services', function(e) { if (result.extra_demands) { $('#popup-view-extra-services').html(''); $('#popup-view-extra-services').append(result.extra_demands); + initPriceCalculationTooltip(); $.fancybox.open({ href: '#popup-view-extra-services', diff --git a/themes/hotel-reservation-theme/js/order-opc.js b/themes/hotel-reservation-theme/js/order-opc.js index 854f90fbb..999f73c67 100644 --- a/themes/hotel-reservation-theme/js/order-opc.js +++ b/themes/hotel-reservation-theme/js/order-opc.js @@ -705,6 +705,7 @@ $(document).ready(function() if (result.extra_demands) { $('#rooms_extra_services').html(''); $('#rooms_extra_services').append(result.extra_demands); + initPriceCalculationTooltip(); } $.fancybox({ href: "#rooms_extra_services", diff --git a/themes/hotel-reservation-theme/js/product.js b/themes/hotel-reservation-theme/js/product.js index 4c375b794..c14bd9cff 100644 --- a/themes/hotel-reservation-theme/js/product.js +++ b/themes/hotel-reservation-theme/js/product.js @@ -1171,6 +1171,7 @@ $(document).ready(function() { triggerElement.hide(); } } + initPriceCalculationTooltip(); } else { triggerElement.hide(); } @@ -1598,4 +1599,4 @@ $(document).on('change', 'input[name="buying_option"]', function() { } else { $('#hotel_selection_block').show(); } -}); \ No newline at end of file +}); From a940ad173e322d755c65776ee6649312b6091328 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Thu, 28 May 2026 19:37:51 +0530 Subject: [PATCH 13/34] Fix: Incorrect Product Selling Type Handling During Order Validation --- .../normal_products/informations.tpl | 6 +- classes/Cart.php | 58 +++++++------ classes/PaymentModule.php | 82 +++++++++++++++---- classes/Product.php | 73 +++++------------ classes/order/OrderDetail.php | 2 +- classes/order/OrderInvoice.php | 10 +-- classes/pdf/HTMLTemplateInvoice.php | 17 +--- classes/pdf/HTMLTemplateOrderSlip.php | 14 ++-- controllers/admin/AdminImportController.php | 4 +- controllers/admin/AdminOrdersController.php | 36 ++++---- controllers/admin/AdminProductsController.php | 4 +- controllers/front/CartController.php | 12 +-- controllers/front/GuestTrackingController.php | 6 +- .../front/OrderConfirmationController.php | 4 +- controllers/front/OrderDetailController.php | 6 +- controllers/front/ProductController.php | 14 ++-- modules/blockcart/blockcart.php | 8 +- modules/blockcart/blockcart.tpl | 6 +- modules/blockcart/cartrow.tpl | 12 +-- .../classes/HotelCartBookingData.php | 6 +- .../AdminHotelRoomsBookingController.php | 2 +- .../modules/blockcart/blockcart.tpl | 8 +- .../modules/blockcart/cartrow.tpl | 2 +- 23 files changed, 205 insertions(+), 187 deletions(-) diff --git a/admin/themes/default/template/controllers/normal_products/informations.tpl b/admin/themes/default/template/controllers/normal_products/informations.tpl index b1d0b9f72..a528df729 100644 --- a/admin/themes/default/template/controllers/normal_products/informations.tpl +++ b/admin/themes/default/template/controllers/normal_products/informations.tpl @@ -241,21 +241,21 @@
diff --git a/classes/Cart.php b/classes/Cart.php index d544f3cf9..813ff4f89 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -827,7 +827,7 @@ class CartCore extends ObjectModel $serviceProducts = array(); $context = Context::getContext(); foreach ($productList as $key => $product) { - if (!$product['booking_product'] && Product::isSellableAsStandalone($product['selling_preference_type'] && !Product::isSellableWithRoomType($product['selling_preference_type']))) { + if (!$product['booking_product'] && Product::isSellableAsStandalone($product['id_product']) && !Product::isSellableWithRoomType($product['id_product'])) { if (Validate::isLoadedObject( $objProduct = new Product($product['id_product'], false, $this->id_lang) )) { @@ -1659,9 +1659,9 @@ class CartCore extends ObjectModel continue; } - $canSellWithRoomType = Product::isSellableWithRoomType($product['selling_preference_type']); - $canSellWithHotel = Product::isSellableWithHotel($product['selling_preference_type']); - $canSellAsStandalone = Product::isSellableAsStandalone($product['selling_preference_type']); + $canSellWithRoomType = Product::isSellableWithRoomType($product['id_product']); + $canSellWithHotel = Product::isSellableWithHotel($product['id_product']); + $canSellAsStandalone = Product::isSellableAsStandalone($product['id_product']); if ($canSellWithRoomType) { if ($type == Cart::ONLY_STANDALONE_PRODUCTS && !$canSellAsStandalone && !$canSellWithHotel) { @@ -1753,9 +1753,6 @@ class CartCore extends ObjectModel $products_total[$id_tax_rules_group.'_'.$id_address] = 0; } if (!$product['booking_product']) { - $canSellWithRoomType = Product::isSellableWithRoomType($product['selling_preference_type']); - $canSellWithHotel = Product::isSellableWithHotel($product['selling_preference_type']); - $canSellAsStandalone = Product::isSellableAsStandalone($product['selling_preference_type']); $isRoomServiceTotalType = in_array($type, array( Cart::ONLY_ROOM_SERVICES, Cart::ONLY_CONVENIENCE_FEE, @@ -1764,10 +1761,28 @@ class CartCore extends ObjectModel Cart::ONLY_ROOM_SERVICES_WITH_AUTO_ADD_WITHOUT_CONVENIENCE_FEE, )); - if ($canSellAsStandalone && !$isRoomServiceTotalType) { - $idHotelCartBooking = isset($product['id_hotel_cart_booking']) ? (int)$product['id_hotel_cart_booking'] : 0; - $idHotel = isset($product['id_hotel']) ? (int)$product['id_hotel'] : 0; + $singleContextSellTypes = [ + Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, + Product::SELLING_PREFERENCE_HOTEL_STANDALONE, + Product::SELLING_PREFERENCE_STANDALONE, + ]; + $specificSellType = ($param_product + && isset($product['selling_preference_type']) + && in_array((int)$product['selling_preference_type'], $singleContextSellTypes)) + ? (int)$product['selling_preference_type'] + : null; + $sellsAsStandalone = $specificSellType !== null + ? ($specificSellType === Product::SELLING_PREFERENCE_STANDALONE) + : Product::isSellableAsStandalone($product['id_product']); + $sellsWithHotel = $specificSellType !== null + ? ($specificSellType === Product::SELLING_PREFERENCE_HOTEL_STANDALONE) + : Product::isSellableWithHotel($product['id_product']); + $sellsWithRoomType = $specificSellType !== null + ? ($specificSellType === Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) + : Product::isSellableWithRoomType($product['id_product']); + + if ($sellsAsStandalone && !$isRoomServiceTotalType) { if ($serviceProducts = $objServiceProductCartDetail->getServiceProductsInCart( $this->id, [], @@ -1791,8 +1806,8 @@ class CartCore extends ObjectModel } } - } - if ($canSellWithHotel ) { + } + if ($sellsWithHotel) { if ($type == Cart::ONLY_ROOM_SERVICES || $type == Cart::ONLY_CONVENIENCE_FEE || $type == Cart::ONLY_ROOM_SERVICES_WITHOUT_AUTO_ADD @@ -1829,7 +1844,7 @@ class CartCore extends ObjectModel if ($serviceProducts) { foreach ($serviceProducts as $serviceProduct) { - if(!empty($serviceProduct['id_hotel']) && empty($serviceProduct['id_hotel_cart_booking'])) { + if (!empty($serviceProduct['id_hotel']) && empty($serviceProduct['id_hotel_cart_booking'])) { if ($with_taxes) { $priceAdd = $serviceProduct['total_price_tax_incl']; } else { @@ -1845,7 +1860,7 @@ class CartCore extends ObjectModel } } } - if ($canSellWithRoomType && $type !== Cart::ONLY_STANDALONE_PRODUCTS) { + if ($sellsWithRoomType && $type !== Cart::ONLY_STANDALONE_PRODUCTS) { if ($servicesWithRoom = $objServiceProductCartDetail->getServiceProductsInCart( $this->id, @@ -2436,7 +2451,7 @@ class CartCore extends ObjectModel } } } else { - if (Product::isSellableWithRoomType($product['selling_preference_type'])) { + if (Product::isSellableWithRoomType($product['id_product'])) { // get standard products which are booked for room types // send id_hotel = 0 for standard products with room types if ($selectedServiceProducts = $objServiceProductCartDetail->getServiceProductsInCart( @@ -2509,7 +2524,7 @@ class CartCore extends ObjectModel } } } - if (Product::isSellableAsStandalone($product['selling_preference_type'])) { + if (Product::isSellableAsStandalone($product['id_product'])) { if ($selectedServiceProducts = $objServiceProductCartDetail->getServiceProductsInCart( $this->id, [], @@ -2566,8 +2581,7 @@ class CartCore extends ObjectModel } } } - - if (Product::isSellableWithHotel($product['selling_preference_type'])) { + if (Product::isSellableWithHotel($product['id_product'])) { if ($selectedServiceProducts = $objServiceProductCartDetail->getServiceProductsInCart( $this->id, [], @@ -3198,11 +3212,9 @@ class CartCore extends ObjectModel $id_address = HotelRoomType::getHotelIdAddressByIdProduct($id_product); } else { // if the product is a standard product the get the address as per the selling preference - $sellingPreferenceType = Product::getSellingPreferenceType($id_product); - - $canSellWithRoomType = Product::isSellableWithRoomType($sellingPreferenceType); - $canSellWithHotel = Product::isSellableWithHotel($sellingPreferenceType); - $canSellAsStandalone = Product::isSellableAsStandalone($sellingPreferenceType); + $canSellWithRoomType = Product::isSellableWithRoomType($id_product); + $canSellWithHotel = Product::isSellableWithHotel($id_product); + $canSellAsStandalone = Product::isSellableAsStandalone($id_product); if ($canSellWithHotel) { if ($htlAddress = HotelBranchInformation::getAddress($id_hotel)) { diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 43158862f..8b6e57e1b 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -589,12 +589,11 @@ abstract class PaymentModuleCore extends Module $virtual_product &= false; } - if ( - !$product['booking_product'] && !$product['id_hotel_cart_booking'] - && ( - Product::isSellableAsStandalone($product['selling_preference_type']) - || Product::isSellableWithHotel($product['selling_preference_type']) - ) + if (!$product['booking_product'] + && ($product['selling_preference_type'] == Product::SELLING_PREFERENCE_STANDALONE + || $product['selling_preference_type'] == Product::SELLING_PREFERENCE_HOTEL_STANDALONE + || $product['selling_preference_type'] == Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE + ) ) { $cover_image_arr = $objProduct->getCover($product['id_product']); @@ -604,11 +603,10 @@ abstract class PaymentModuleCore extends Module $cover_img = $this->context->link->getImageLink($product['link_rewrite'], $this->context->language->iso_code."-default", 'small_default'); } $product_var_tpl['cover_img'] = $cover_img; - $idHotel = isset($product['id_hotel']) ? $product['id_hotel'] : 0; $serviceProducts = $objServiceProductCartDetail->getServiceProductsInCart( $order->id_cart, [], - $idHotel, + null, 0, null, $product['id_product'] @@ -966,11 +964,9 @@ abstract class PaymentModuleCore extends Module if (!empty($normalProducts)) { $objServiceProductCartDetail = new ServiceProductCartDetail(); - foreach ($normalProducts as $product) { + foreach($normalProducts as $product) { $idProduct = $product['id_product']; - $productSellingType = $product['selling_preference_type']; - - if (Product::isSellableWithRoomType($productSellingType)) { + if (Product::SELLING_PREFERENCE_WITH_ROOM_TYPE == $product['selling_preference_type']) { if ($roomTypeServices = $objServiceProductCartDetail->getServiceProductsInCart( $this->context->cart->id, [], @@ -979,7 +975,6 @@ abstract class PaymentModuleCore extends Module null, $product['id_product'] )) { - $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct($idProduct, $order->id, $product['selling_preference_type']); foreach ($roomTypeServices as $roomTypeService) { if (!$roomTypeService['id_hotel_cart_booking']) { @@ -1008,7 +1003,7 @@ abstract class PaymentModuleCore extends Module $objServiceProductOrderDetail->save(); } } - } elseif (Product::isSellableWithHotel($productSellingType)) { + } elseif (Product::SELLING_PREFERENCE_HOTEL_STANDALONE == $product['selling_preference_type']) { if ($hotelProducts = $objServiceProductCartDetail->getServiceProductsInCart( $this->context->cart->id, [], @@ -1042,7 +1037,7 @@ abstract class PaymentModuleCore extends Module } } - } elseif (Product::isSellableAsStandalone($productSellingType)) { + } elseif (Product::SELLING_PREFERENCE_STANDALONE == $product['selling_preference_type']) { if ($standaloneProducts = $objServiceProductCartDetail->getServiceProductsInCart( $this->context->cart->id, [], @@ -1067,6 +1062,63 @@ abstract class PaymentModuleCore extends Module $objServiceProductOrderDetail->option_name = $standaloneProduct['option_name']; $objServiceProductOrderDetail->quantity = $standaloneProduct['quantity']; $objServiceProductOrderDetail->save(); + + } + } + } elseif (Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE == $product['selling_preference_type']) { + $idProductRoomType = null; + $idProductHotel = null; + if (isset($product['id_room_type']) && $product['id_room_type']) { + $idProductRoomType = $product['id_room_type']; + } elseif (isset($product['id_hotel']) && $product['id_hotel']) { + $idProductHotel = $product['id_hotel']; + } + if ($serviceProducts = $objServiceProductCartDetail->getServiceProductsInCart( + $this->context->cart->id, + [], + $idProductHotel, + null, + $idProductRoomType, + $product['id_product'] + )) { + foreach ($serviceProducts as $serviceProduct) { + if ($serviceProduct['id_hotel']) { + $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct($idProduct, $order->id, Product::SELLING_PREFERENCE_HOTEL_STANDALONE); + } else { + $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct($idProduct, $order->id, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE); + } + $objServiceProductOrderDetail = new ServiceProductOrderDetail(); + $objServiceProductOrderDetail->id_product = $idProduct; + $objServiceProductOrderDetail->id_order = $order->id; + $objServiceProductOrderDetail->id_order_detail = $idOrderDetail; + $objServiceProductOrderDetail->id_cart = $this->context->cart->id; + $objServiceProductOrderDetail->unit_price_tax_excl = $serviceProduct['unit_price_tax_excl']; + $objServiceProductOrderDetail->unit_price_tax_incl = $serviceProduct['unit_price_tax_incl']; + $objServiceProductOrderDetail->total_price_tax_excl = $serviceProduct['total_price_tax_excl']; + $objServiceProductOrderDetail->total_price_tax_incl = $serviceProduct['total_price_tax_incl']; + $objServiceProductOrderDetail->name = $product['name']; + $objServiceProductOrderDetail->quantity = $serviceProduct['quantity']; + $objServiceProductOrderDetail->id_product_option = $serviceProduct['id_product_option']; + $objServiceProductOrderDetail->option_name = $serviceProduct['option_name']; + if ($serviceProduct['id_hotel']) { + $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; + } + } else { + $roomBookingDetail = $objBookingDetail->getRowByIdOrderIdProductInDateRange( + $order->id, + $serviceProduct['id_room_type'], + $serviceProduct['date_from'], + $serviceProduct['date_to'], + $serviceProduct['id_room'] + ); + $objServiceProductOrderDetail->id_htl_booking_detail = $roomBookingDetail['id']; + $objServiceProductOrderDetail->auto_added = $product['auto_add_to_cart']; + } + $objServiceProductOrderDetail->save(); } } } diff --git a/classes/Product.php b/classes/Product.php index 3267ff979..32c6d0bfe 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -6938,64 +6938,33 @@ class ProductCore extends ObjectModel } } - public static function getSellingPreferenceChannels($sellingPreferenceType) + public static function isSellableWithRoomType($idProduct) { - $channels = [ - 'with_room_type' => false, - 'with_hotel' => false, - 'standalone' => false, - ]; - - switch ((int) $sellingPreferenceType) { - case self::SELLING_PREFERENCE_WITH_ROOM_TYPE: - $channels['with_room_type'] = true; - break; - - case self::SELLING_PREFERENCE_HOTEL_STANDALONE: - $channels['with_hotel'] = true; - break; - - case self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE: - $channels['with_room_type'] = true; - $channels['with_hotel'] = true; - break; - - case self::SELLING_PREFERENCE_STANDALONE: - $channels['standalone'] = true; - break; - - case self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE: - $channels['with_hotel'] = true; - $channels['standalone'] = true; - break; - - case self::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE: - $channels['with_room_type'] = true; - $channels['standalone'] = true; - break; - - case self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE: - $channels['with_room_type'] = true; - $channels['with_hotel'] = true; - $channels['standalone'] = true; - break; - } - - return $channels; + return in_array((int) self::getSellingPreferenceType($idProduct), [ + self::SELLING_PREFERENCE_WITH_ROOM_TYPE, + self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, + self::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, + self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, + ]); } - public static function isSellableWithRoomType($sellingPreferenceType) + public static function isSellableWithHotel($idProduct) { - return self::getSellingPreferenceChannels($sellingPreferenceType)['with_room_type']; + return in_array((int) self::getSellingPreferenceType($idProduct), [ + self::SELLING_PREFERENCE_HOTEL_STANDALONE, + self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, + self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, + self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, + ]); } - public static function isSellableWithHotel($sellingPreferenceType) + public static function isSellableAsStandalone($idProduct) { - return self::getSellingPreferenceChannels($sellingPreferenceType)['with_hotel']; - } - - public static function isSellableAsStandalone($sellingPreferenceType) - { - return self::getSellingPreferenceChannels($sellingPreferenceType)['standalone']; + return in_array((int) self::getSellingPreferenceType($idProduct), [ + self::SELLING_PREFERENCE_STANDALONE, + self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, + self::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, + self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, + ]); } } diff --git a/classes/order/OrderDetail.php b/classes/order/OrderDetail.php index 926020678..f9e165503 100644 --- a/classes/order/OrderDetail.php +++ b/classes/order/OrderDetail.php @@ -390,7 +390,7 @@ class OrderDetailCore extends ObjectModel /** * Calculate tax rule groups for the service product based on each associated room type. */ - if (!$this->is_booking_product && Product::isSellableWithRoomType($this->selling_preference_type)) { + if (!$this->is_booking_product && $this->selling_preference_type == Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) { if ($this->product_auto_add && $this->product_price_addition_type == Product::PRICE_ADDITION_TYPE_WITH_ROOM) { return true; } diff --git a/classes/order/OrderInvoice.php b/classes/order/OrderInvoice.php index 457a0baa9..f3e79c9d5 100644 --- a/classes/order/OrderInvoice.php +++ b/classes/order/OrderInvoice.php @@ -415,7 +415,7 @@ class OrderInvoiceCore extends ObjectModel $order_detail = array_filter($order_detail, function($v) { return ($v['is_booking_product'] || ($v['product_auto_add'] - && Product::isSellableWithRoomType($v['selling_preference_type']) + && $v['selling_preference_type'] == Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $v['product_price_addition_type'] == ProductCore::PRICE_ADDITION_TYPE_WITH_ROOM) ); }); @@ -480,7 +480,7 @@ class OrderInvoiceCore extends ObjectModel $breakdown = array(); $order_detail = $this->getProducts(); $order_detail = array_filter($order_detail, function($v) { - return (!$v['is_booking_product'] && !$v['product_auto_add'] && Product::isSellableWithRoomType($v['selling_preference_type'])); + return (!$v['is_booking_product'] && !$v['product_auto_add'] && $v['selling_preference_type'] == Product::SELLING_PREFERENCE_WITH_ROOM_TYPE); }); $details = $order->getProductTaxesDetails($order_detail, false,Product::SELLING_PREFERENCE_WITH_ROOM_TYPE); @@ -545,7 +545,7 @@ class OrderInvoiceCore extends ObjectModel $order_detail = array_filter($order_detail, function($v) { return (!$v['is_booking_product'] && $v['product_auto_add'] - && Product::isSellableWithRoomType($v['selling_preference_type']) + && $v['selling_preference_type'] == Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $v['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT ); }); @@ -612,8 +612,8 @@ class OrderInvoiceCore extends ObjectModel $order_detail = $this->getProducts(); $order_detail = array_filter($order_detail, function($v) { return (!$v['is_booking_product'] && ( - Product::isSellableAsStandalone($v['selling_preference_type']) - || Product::isSellableWithHotel($v['selling_preference_type']) + $v['selling_preference_type'] == Product::SELLING_PREFERENCE_STANDALONE + || $v['selling_preference_type'] == Product::SELLING_PREFERENCE_HOTEL_STANDALONE )); }); diff --git a/classes/pdf/HTMLTemplateInvoice.php b/classes/pdf/HTMLTemplateInvoice.php index 37b895353..c23fdd280 100644 --- a/classes/pdf/HTMLTemplateInvoice.php +++ b/classes/pdf/HTMLTemplateInvoice.php @@ -607,9 +607,8 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate foreach ($cart_htl_data[$type_key]['date_diff'] as $key => &$value) { $value['avg_paid_unit_price_tax_excl'] = Tools::ps_round($value['avg_paid_unit_price_tax_excl'] / $value['num_rm'], 6); } - } else if ( - Product::isSellableWithHotel($type_value['selling_preference_type']) - || Product::isSellableAsStandalone($type_value['selling_preference_type']) + } else if (Product::SELLING_PREFERENCE_HOTEL_STANDALONE == $type_value['selling_preference_type'] + || Product::SELLING_PREFERENCE_STANDALONE == $type_value['selling_preference_type'] ) { $serviceProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($order_obj->id, $type_value['id_order_detail'], $type_value['product_id']); if ($taxes = OrderDetail::getTaxListStatic($type_value['id_order_detail'])) { @@ -623,17 +622,7 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate $order_detail_tax_label = HTMLTemplateInvoice::l('No tax'); } foreach ($serviceProducts as $serviceProduct) { - $isStandaloneRow = empty($serviceProduct['id_hotel']) && empty($serviceProduct['id_htl_booking_detail']); - $isHotelRow = !empty($serviceProduct['id_hotel']) && empty($serviceProduct['id_htl_booking_detail']); - - if (!( - ($isStandaloneRow && Product::isSellableAsStandalone($type_value['selling_preference_type'])) - || ($isHotelRow && Product::isSellableWithHotel($type_value['selling_preference_type'])) - )) { - continue; - } - - if ($isHotelRow) { + if ($serviceProduct['id_hotel']) { $objHotel = new HotelBranchInformation($serviceProduct['id_hotel'], $order_obj->id_lang); $serviceProduct['hotel_name'] = $objHotel->hotel_name; } diff --git a/classes/pdf/HTMLTemplateOrderSlip.php b/classes/pdf/HTMLTemplateOrderSlip.php index 0c2a50c86..16396243f 100644 --- a/classes/pdf/HTMLTemplateOrderSlip.php +++ b/classes/pdf/HTMLTemplateOrderSlip.php @@ -286,7 +286,7 @@ class HTMLTemplateOrderSlipCore extends HTMLTemplateInvoice $order_detail = array_filter($this->order->products, function($v) { return ((isset($v['is_booking_product']) && $v['is_booking_product']) || ((isset($v['product_auto_add']) && $v['product_auto_add']) - && Product::isSellableWithRoomType($v['selling_preference_type']) + && $v['selling_preference_type'] == Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $v['product_price_addition_type'] == ProductCore::PRICE_ADDITION_TYPE_WITH_ROOM) ); }); @@ -347,14 +347,10 @@ class HTMLTemplateOrderSlipCore extends HTMLTemplateInvoice // - 'total_amount' $breakdown = array(); $order_detail = array_filter($this->order->products, function($v) { - return ( - !$v['is_booking_product'] - && empty($v['id_htl_booking']) - && ( - Product::isSellableAsStandalone($v['selling_preference_type']) - || Product::isSellableWithHotel($v['selling_preference_type']) - ) - ); + return (!$v['is_booking_product'] && ( + $v['selling_preference_type'] == Product::SELLING_PREFERENCE_STANDALONE + || $v['selling_preference_type'] == Product::SELLING_PREFERENCE_HOTEL_STANDALONE + )); }); $details = $this->order->getProductTaxesDetails($order_detail, false); diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index 60cfce9a0..060a01970 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -1901,7 +1901,7 @@ class AdminImportControllerCore extends AdminController } $objServiceProduct = new Product($idServiceProduct); - if (Product::isSellableWithRoomType($objServiceProduct->selling_preference_type)) { + if (Product::isSellableWithRoomType($objServiceProduct->id)) { $objRoomTypeServiceProduct->addRoomProductLink( $objServiceProduct->id, $product->id, @@ -2329,7 +2329,7 @@ class AdminImportControllerCore extends AdminController $info['shop'] = explode($this->multiple_value_separator, $info['shop']); RoomTypeServiceProduct::deleteRoomProductLink($product->id); - if (Product::isSellableWithRoomType($product->selling_preference_type)) { + if (Product::isSellableWithRoomType($product->id)) { $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); if (isset($info['id_room_types']) && $info['id_room_types']) { $objRoomTypeServiceProduct->addRoomProductLink( diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index ba8a1e481..fcf696f8a 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -3357,14 +3357,14 @@ class AdminOrdersControllerCore extends AdminController } else { $product['image_link'] = $this->context->link->getImageLink($objProduct->link_rewrite, $this->context->language->iso_code.'-default', 'small_default'); } - if (Product::isSellableWithHotel($product['selling_preference_type']) - || Product::isSellableAsStandalone($product['selling_preference_type']) + if (Product::isSellableWithHotel($product['product_id']) + || Product::isSellableAsStandalone($product['product_id']) ) { $serviceProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($order->id, $product['id_order_detail'], $product['product_id']); foreach ($serviceProducts as $serviceProduct) { - if (!empty($serviceProduct['id_hotel']) && Product::isSellableWithHotel($product['selling_preference_type'])) { + if (!empty($serviceProduct['id_hotel']) && Product::isSellableWithHotel($product['product_id'])) { $orderHotelServiceProducts[] = array_merge($product, $serviceProduct); - } elseif (!$serviceProduct['id_hotel'] && !$serviceProduct['id_htl_booking_detail'] && Product::isSellableAsStandalone($product['selling_preference_type'])) { + } elseif (!$serviceProduct['id_hotel'] && !$serviceProduct['id_htl_booking_detail'] && Product::isSellableAsStandalone($product['product_id'])) { $orderStandaloneServiceProducts[] = array_merge($product, $serviceProduct); } } @@ -3702,10 +3702,10 @@ class AdminOrdersControllerCore extends AdminController $hotelStandaloneProducts = array(); $standaloneProducts = array(); foreach ($allServiceProducts as $serviceProduct) { - if (Product::isSellableWithHotel($serviceProduct['selling_preference_type'])) { + if (Product::isSellableWithHotel($serviceProduct['id_product'])) { $hotelStandaloneProducts[] = $serviceProduct; } - if (Product::isSellableAsStandalone($serviceProduct['selling_preference_type'])) { + if (Product::isSellableAsStandalone($serviceProduct['id_product'])) { $standaloneProducts[] = $serviceProduct; } } @@ -4484,9 +4484,9 @@ class AdminOrdersControllerCore extends AdminController if ($product->booking_product || ( - Product::isSellableWithRoomType($product->selling_preference_type) - && !Product::isSellableWithHotel($product->selling_preference_type) - && !Product::isSellableAsStandalone($product->selling_preference_type) + Product::isSellableWithRoomType($product->id) + && !Product::isSellableWithHotel($product->id) + && !Product::isSellableAsStandalone($product->id) ) ) { die(Tools::jsonEncode(array( 'result' => false, @@ -5585,14 +5585,14 @@ class AdminOrdersControllerCore extends AdminController $response['error'] = Tools::displayError('The product object cannot be loaded.'); } elseif ($objProduct->booking_product || ( - Product::isSellableWithRoomType($objProduct->selling_preference_type) - && !Product::isSellableWithHotel($objProduct->selling_preference_type) - && !Product::isSellableAsStandalone($objProduct->selling_preference_type) + Product::isSellableWithRoomType($objProduct->id) + && !Product::isSellableWithHotel($objProduct->id) + && !Product::isSellableAsStandalone($objProduct->id) ) ) { $response['status'] = false; $response['error'] = Tools::displayError('Invalid product. Please try adding any other product.'); - } elseif (!Product::isSellableAsStandalone($objProduct->selling_preference_type) + } elseif (!Product::isSellableAsStandalone($objProduct->id) && (!$addressTax->id_hotel || !Validate::isLoadedObject($objHotel = new HotelBranchInformation($addressTax->id_hotel))) ) { @@ -5692,8 +5692,8 @@ class AdminOrdersControllerCore extends AdminController if ($response['status']) { // If product is standalone and current order is for a hotel then we have to create a new order for this product $response['new_id_order'] = 0; - if (Product::isSellableAsStandalone($objProduct->selling_preference_type) - && !Product::isSellableWithHotel($objProduct->selling_preference_type) + if (Product::isSellableAsStandalone($objProduct->id) + && !Product::isSellableWithHotel($objProduct->id) && $addressTax->id_hotel ) { $objPaymentModule = new BoOrder(); @@ -5777,9 +5777,9 @@ class AdminOrdersControllerCore extends AdminController $objOrderDetail = new OrderDetail(); $cartProducts = $objCart->getProducts(); - if (Product::isSellableWithHotel($cartProducts[0]['selling_preference_type']) && $addressTax->id_hotel) { + if (Product::isSellableWithHotel($cartProducts[0]['id_product']) && $addressTax->id_hotel) { $cartProducts[0]['selling_preference_type'] = Product::SELLING_PREFERENCE_HOTEL_STANDALONE; - } elseif (Product::isSellableAsStandalone($cartProducts[0]['selling_preference_type'])) { + } elseif (Product::isSellableAsStandalone($cartProducts[0]['id_product'])) { $cartProducts[0]['selling_preference_type'] = Product::SELLING_PREFERENCE_STANDALONE; } $objOrderDetail->createList($objOrder, $objCart, $objOrder->getCurrentOrderState(), $cartProducts, (isset($objOrderInvoice) ? $objOrderInvoice->id : 0), $useTaxes, (int)Tools::getValue('add_product_warehouse')); @@ -7993,7 +7993,7 @@ class AdminOrdersControllerCore extends AdminController $product['total'] = $totalPriceTaxExcl; $product['total_wt'] = $totalPriceTaxIncl; - if (Product::isSellableWithRoomType($product['selling_preference_type'])) { + if (Product::isSellableWithRoomType($product['id_product'])) { $product['selling_preference_type'] = Product::SELLING_PREFERENCE_WITH_ROOM_TYPE; } } diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 29518137e..445f7ba96 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -418,7 +418,7 @@ class AdminProductsControllerCore extends AdminController $allServiceProducts = array_values(array_filter( $objProduct->getServiceProducts(null), function ($serviceProduct) { - return Product::isSellableWithRoomType($serviceProduct['selling_preference_type']); + return Product::isSellableWithRoomType($serviceProduct['id_product']); } )); $serviceProducts = array(); @@ -3227,7 +3227,7 @@ class AdminProductsControllerCore extends AdminController $allServiceProducts = array_values(array_filter( $obj->getServiceProducts(null), function ($serviceProduct) { - return Product::isSellableWithRoomType($serviceProduct['selling_preference_type']); + return Product::isSellableWithRoomType($serviceProduct['id_product']); } )); diff --git a/controllers/front/CartController.php b/controllers/front/CartController.php index 67ee06439..10df365a1 100644 --- a/controllers/front/CartController.php +++ b/controllers/front/CartController.php @@ -180,8 +180,8 @@ class CartControllerCore extends FrontController } } else { $idProductOption = Tools::getValue('id_product_option', null); - $canSellWithHotel = Product::isSellableWithHotel($product->selling_preference_type); - $canSellStandalone = Product::isSellableAsStandalone($product->selling_preference_type); + $canSellWithHotel = Product::isSellableWithHotel($product->id); + $canSellStandalone = Product::isSellableAsStandalone($product->id); if ($canSellWithHotel && $this->id_hotel) { $objServiceProductCartDetail = new ServiceProductCartDetail(); @@ -460,8 +460,8 @@ class CartControllerCore extends FrontController $objHotelCartBookingData = new HotelCartBookingData(); $idProductOption = Tools::getValue('id_product_option'); $id_hotel = (int) Tools::getValue('id_hotel'); - $canSellWithHotel = Product::isSellableWithHotel($product->selling_preference_type); - $canSellStandalone = Product::isSellableAsStandalone($product->selling_preference_type); + $canSellWithHotel = Product::isSellableWithHotel($product->id); + $canSellStandalone = Product::isSellableAsStandalone($product->id); if ($canSellWithHotel && $id_hotel) { if ($operator == 'up') { @@ -643,7 +643,7 @@ class CartControllerCore extends FrontController } $this->context->cookie->avail_rooms = $availQty; } elseif ( - Product::isSellableWithHotel($product->selling_preference_type) + Product::isSellableWithHotel($product->id) && $id_hotel ) { $objServiceProductCartDetail = new ServiceProductCartDetail(); @@ -664,7 +664,7 @@ class CartControllerCore extends FrontController 'id_product_option' => isset($idProductOption) ? $idProductOption : null )); } - } elseif (Product::isSellableAsStandalone($product->selling_preference_type)) { + } elseif (Product::isSellableAsStandalone($product->id)) { $objServiceProductCartDetail = new ServiceProductCartDetail(); $update_quantity = $objServiceProductCartDetail->updateCartServiceProduct( $this->context->cart->id, diff --git a/controllers/front/GuestTrackingController.php b/controllers/front/GuestTrackingController.php index 3b6fd2b2b..991ffa5c5 100644 --- a/controllers/front/GuestTrackingController.php +++ b/controllers/front/GuestTrackingController.php @@ -497,7 +497,7 @@ class GuestTrackingControllerCore extends FrontController $value['avg_price_diff_tax_excl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_excl'] - $value['product_price_tax_excl'], 6)); $value['avg_price_diff_tax_incl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_incl'] - $value['product_price_tax_incl'], 6)); } - } elseif (Product::isSellableWithRoomType($type_value['selling_preference_type'])) { + } elseif (Product::SELLING_PREFERENCE_WITH_ROOM_TYPE == $type_value['selling_preference_type']) { if ($type_value['product_auto_add'] && $type_value['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT) { $total_convenience_fee_ti += $objServiceProductOrderDetail->getRoomTypeServiceProducts( $idOrder, @@ -524,7 +524,7 @@ class GuestTrackingControllerCore extends FrontController 1 ); } - } else if (Product::isSellableWithHotel($type_value['selling_preference_type'])) { + } else if (Product::SELLING_PREFERENCE_HOTEL_STANDALONE == $type_value['selling_preference_type']) { $cover_image_arr = $product->getCover($type_value['product_id']); if (!empty($cover_image_arr)) { @@ -536,7 +536,7 @@ class GuestTrackingControllerCore extends FrontController foreach ($hotelProducts as $hotelProduct) { $hotelServiceProducts[] = array_merge($type_value, $hotelProduct); } - } else if (Product::isSellableAsStandalone($type_value['selling_preference_type'])) { + } else if (Product::SELLING_PREFERENCE_STANDALONE == $type_value['selling_preference_type']) { $cover_image_arr = $product->getCover($type_value['product_id']); if (!empty($cover_image_arr)) { diff --git a/controllers/front/OrderConfirmationController.php b/controllers/front/OrderConfirmationController.php index e40a7bec0..dd428dff2 100644 --- a/controllers/front/OrderConfirmationController.php +++ b/controllers/front/OrderConfirmationController.php @@ -362,7 +362,7 @@ class OrderConfirmationControllerCore extends FrontController $totalRoomsBooked += 1; } - } else if (Product::isSellableWithHotel($type_value['selling_preference_type'])) { + } else if ($type_value['selling_preference_type'] == Product::SELLING_PREFERENCE_HOTEL_STANDALONE) { $cover_image_arr = $product->getCover($type_value['product_id']); if (!empty($cover_image_arr)) { @@ -385,7 +385,7 @@ class OrderConfirmationControllerCore extends FrontController } $cart_hotel_service_products[] = $type_value; } - } else if (Product::isSellableAsStandalone($type_value['selling_preference_type'])) { + } else if ($type_value['selling_preference_type'] == Product::SELLING_PREFERENCE_STANDALONE) { $cover_image_arr = $product->getCover($type_value['product_id']); if (!empty($cover_image_arr)) { diff --git a/controllers/front/OrderDetailController.php b/controllers/front/OrderDetailController.php index c71439dab..0a949c7e4 100644 --- a/controllers/front/OrderDetailController.php +++ b/controllers/front/OrderDetailController.php @@ -358,7 +358,7 @@ class OrderDetailControllerCore extends FrontController $value['avg_price_diff_tax_excl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_excl'] - $value['product_price_tax_excl'], 6)); $value['avg_price_diff_tax_incl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_incl'] - $value['product_price_tax_incl'], 6)); } - } else if (Product::isSellableWithRoomType($type_value['selling_preference_type'])) { + } else if (Product::SELLING_PREFERENCE_WITH_ROOM_TYPE ==$type_value['selling_preference_type']) { if ($type_value['product_auto_add'] && $type_value['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT) { $total_convenience_fee_ti += $objServiceProductOrderDetail->getRoomTypeServiceProducts( $id_order, @@ -385,7 +385,7 @@ class OrderDetailControllerCore extends FrontController 1 ); } - } else if (Product::isSellableWithHotel($type_value['selling_preference_type'])) { + } else if (Product::SELLING_PREFERENCE_HOTEL_STANDALONE == $type_value['selling_preference_type']) { $hotelProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($id_order, $type_value['id_order_detail'], $type_value['product_id']); foreach ($hotelProducts as $hotelProduct) { $hotelServiceProducts[] = array_merge($type_value, $hotelProduct); @@ -404,7 +404,7 @@ class OrderDetailControllerCore extends FrontController } $serviceProductsFormatted[$hotelProduct['id_product']]['options'][] = $hotelProduct; } - } else if (Product::isSellableAsStandalone($type_value['selling_preference_type'])) { + } else if (Product::SELLING_PREFERENCE_STANDALONE == $type_value['selling_preference_type']) { $standaloneProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($id_order, $type_value['id_order_detail'], $type_value['product_id']); foreach ($standaloneProducts as $standaloneProduct) { $standaloneServiceProducts[] = array_merge($type_value, $standaloneProduct); diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index 22e74f24b..4eeaaa987 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -135,12 +135,12 @@ class ProductControllerCore extends FrontController // if product is a service product then check type of selling preference if (!$this->product->booking_product) { if ( - Product::isSellableWithRoomType($this->product->selling_preference_type) - && !Product::isSellableWithHotel($this->product->selling_preference_type) - && !Product::isSellableAsStandalone($this->product->selling_preference_type) + Product::isSellableWithRoomType($this->product->id) + && !Product::isSellableWithHotel($this->product->id) + && !Product::isSellableAsStandalone($this->product->id) ) { Tools::redirect($this->context->link->getPageLink('pagenotfound')); - } elseif (Product::isSellableWithHotel($this->product->selling_preference_type)) { + } elseif (Product::isSellableWithHotel($this->product->id)) { // For any hotel-sellable service product, ensure hotel associations exist. $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); $associatedHotels = $objRoomTypeServiceProduct->getAssociatedHotelsAndRoomType($this->product->id); @@ -921,9 +921,9 @@ class ProductControllerCore extends FrontController $buying_option = false ) { $smartyVars = array(); - $smartyVars['sellable_with_hotel'] = Product::isSellableWithHotel($this->product->selling_preference_type); - $smartyVars['sellable_as_standalone'] = Product::isSellableAsStandalone($this->product->selling_preference_type); - if (Product::isSellableWithHotel($this->product->selling_preference_type)) { + $smartyVars['sellable_with_hotel'] = Product::isSellableWithHotel($this->product->id); + $smartyVars['sellable_as_standalone'] = Product::isSellableAsStandalone($this->product->id); + if (Product::isSellableWithHotel($this->product->id)) { $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); if ($associatedHotels = $objRoomTypeServiceProduct->getAssociatedHotelsAndRoomType($this->product->id)['hotel']) { diff --git a/modules/blockcart/blockcart.php b/modules/blockcart/blockcart.php index 2c2ea59ac..163d14acd 100644 --- a/modules/blockcart/blockcart.php +++ b/modules/blockcart/blockcart.php @@ -121,7 +121,7 @@ class Blockcart extends Module if (!$product['booking_product']) { $product['hasOptions'] = ServiceProductOption::productHasOptions($product['id_product']); - if (Product::isSellableAsStandalone($product['selling_preference_type'])) { + if (Product::isSellableAsStandalone($product['id_product'])) { $product['total_price_tax_incl'] = 0; $product['total_price_tax_excl'] = 0; $product['amount'] = 0; @@ -148,7 +148,7 @@ class Blockcart extends Module $nbTotalProducts += (int) $product['standalone_total_qty']; } - if (Product::isSellableWithHotel($product['selling_preference_type'])) { + if (Product::isSellableWithHotel($product['id_product'])) { if ($serviceProducts = $objServiceProductCartDetail->getServiceProductsInCart( $params['cart']->id, [(int) $product['selling_preference_type']], @@ -322,8 +322,8 @@ class Blockcart extends Module $addedProduct['date_from'] = Tools::displayDate($addedProduct['date_from'], null, $fullDate); $addedProduct['date_to'] = Tools::displayDate($addedProduct['date_to'], null, $fullDate); } else { - $canSellWithHotel = Product::isSellableWithHotel($objProduct->selling_preference_type); - $canSellStandalone = Product::isSellableAsStandalone($objProduct->selling_preference_type); + $canSellWithHotel = Product::isSellableWithHotel($objProduct->id); + $canSellStandalone = Product::isSellableAsStandalone($objProduct->id); if ($canSellWithHotel && !empty($addedProduct['id_hotel'])) { $addedProduct['unit_price'] = RoomTypeServiceProductPrice::getPrice( diff --git a/modules/blockcart/blockcart.tpl b/modules/blockcart/blockcart.tpl index ec29d14f4..6caf931e7 100644 --- a/modules/blockcart/blockcart.tpl +++ b/modules/blockcart/blockcart.tpl @@ -63,15 +63,15 @@
{foreach from=$products key=data_k item='product' name='myLoop'} {* only show products that are booking or global without room *} - {if $product.booking_product || Product::isSellableAsStandalone($product.selling_preference_type) || Product::isSellableWithHotel($product.selling_preference_type)} + {if $product.booking_product || Product::isSellableAsStandalone($product.id_product) || Product::isSellableWithHotel($product.id_product)} {if isset($product.hotel_wise_data) && $product.hotel_wise_data} {foreach $product.hotel_wise_data as $hotel_wise_data} {include file="./cartrow.tpl" hotel_wise_data=$hotel_wise_data} {/foreach} {/if} {if $product.booking_product - || (!Product::isSellableWithHotel($product.selling_preference_type) && !Product::isSellableWithRoomType($product.selling_preference_type)) - || (Product::isSellableAsStandalone($product.selling_preference_type) && $product.standalone_total_qty > 0)} + || (!Product::isSellableWithHotel($product.id_product) && !Product::isSellableWithRoomType($product.id_product)) + || (Product::isSellableAsStandalone($product.id_product) && $product.standalone_total_qty > 0)} {include file="./cartrow.tpl" hotel_wise_data=false} {/if} {/if} diff --git a/modules/blockcart/cartrow.tpl b/modules/blockcart/cartrow.tpl index 68d0cbc96..16363bca3 100644 --- a/modules/blockcart/cartrow.tpl +++ b/modules/blockcart/cartrow.tpl @@ -11,7 +11,7 @@
{/block} {block name='blockcart_shopping_cart_hotel_name'} - {if Product::isSellableWithHotel($product.selling_preference_type)} + {if Product::isSellableWithHotel($product.id_product)}
{$hotel_wise_data.hotel_name|escape:'html':'UTF-8'}
@@ -29,7 +29,7 @@ {if !isset($product.is_gift) || !$product.is_gift} {if $product.booking_product} {displayWtPrice p="`$product.bookingData.total_room_type_amount`"} - {else if Product::isSellableWithHotel($product.selling_preference_type)} + {else if Product::isSellableWithHotel($product.id_product)} {if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice p="`$hotel_wise_data.total_price_tax_excl`"}{else}{displayWtPrice p="`$hotel_wise_data.total_price_tax_incl`"}{/if} {else} {if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice p="`$product.total_price_tax_excl`"}{else}{displayWtPrice p="`$product.total_price_tax_incl`"}{/if} @@ -53,9 +53,9 @@ {if $product.booking_product} {$product.bookingData['total_num_rooms']} {elseif $product.allow_multiple_quantity} - {if Product::isSellableWithHotel($product.selling_preference_type)} + {if Product::isSellableWithHotel($product.id_product)} {$hotel_wise_data.total_qty} - {elseif Product::isSellableAsStandalone($product.selling_preference_type)} + {elseif Product::isSellableAsStandalone($product.id_product)} {$product.cart_quantity} {/if} {/if} @@ -99,9 +99,9 @@ {/block} {else if $product.hasOptions} {block name='blockcart_shopping_cart_options'} - {if Product::isSellableWithHotel($product.selling_preference_type)} + {if Product::isSellableWithHotel($product.id_product)} {assign var='options' value=$hotel_wise_data.options} - {else if Product::isSellableAsStandalone($product.selling_preference_type)} + {else if Product::isSellableAsStandalone($product.id_product)} {assign var='options' value=$product.options} {/if}
diff --git a/modules/hotelreservationsystem/classes/HotelCartBookingData.php b/modules/hotelreservationsystem/classes/HotelCartBookingData.php index 4a8565923..b77b92d4a 100644 --- a/modules/hotelreservationsystem/classes/HotelCartBookingData.php +++ b/modules/hotelreservationsystem/classes/HotelCartBookingData.php @@ -961,9 +961,9 @@ class HotelCartBookingData extends ObjectModel if (!$product->active || (!$forAdminCart && !$product->available_for_order)) { $toRemoveService = 1; } else if ($checkServiceRoomLink) { - $isSellableWithRoomType = Product::isSellableWithRoomType($product->selling_preference_type); - $isSellableWithHotel = Product::isSellableWithHotel($product->selling_preference_type); - $isSellableAsStandalone = Product::isSellableAsStandalone($product->selling_preference_type); + $isSellableWithRoomType = Product::isSellableWithRoomType($product->id); + $isSellableWithHotel = Product::isSellableWithHotel($product->id); + $isSellableAsStandalone = Product::isSellableAsStandalone($product->id); if (ServiceProductOption::productHasOptions($service['id_product'])) { $skipOptionValidation = false; diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php index 591e0d89d..e2572d465 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php @@ -624,7 +624,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController if (!$product->id || !$product->active) { $this->errors[] = $this->l('This product is no longer available.'); } - if ($product->booking_product || !Product::isSellableAsStandalone($product->selling_preference_type)) { + if ($product->booking_product || !Product::isSellableAsStandalone($product->id)) { // cannot be added without room type or is a booking product. $this->errors[] = $this->l('This product is either a room type or additional service and cannot be added through this method.'); } elseif (!$product->allow_multiple_quantity) { diff --git a/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl b/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl index 182945dfe..47121ca96 100644 --- a/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl +++ b/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl @@ -63,15 +63,15 @@
{foreach from=$products key=data_k item='product' name='myLoop'} {* only show products that are booking or global without room *} - {if $product.booking_product || Product::isSellableAsStandalone($product.selling_preference_type) || Product::isSellableWithHotel($product.selling_preference_type)} - {if Product::isSellableWithHotel($product.selling_preference_type) && isset($product.hotel_wise_data) && $product.hotel_wise_data} + {if $product.booking_product || Product::isSellableAsStandalone($product.id_product) || Product::isSellableWithHotel($product.id_product)} + {if Product::isSellableWithHotel($product.id_product) && isset($product.hotel_wise_data) && $product.hotel_wise_data} {foreach $product.hotel_wise_data as $hotel_wise_data} {include file="./cartrow.tpl" hotel_wise_data=$hotel_wise_data} {/foreach} {/if} {if $product.booking_product - || (!Product::isSellableWithHotel($product.selling_preference_type) && !Product::isSellableWithRoomType($product.selling_preference_type)) - || (Product::isSellableAsStandalone($product.selling_preference_type) && $product.standalone_total_qty > 0)} + || (!Product::isSellableWithHotel($product.id_product) && !Product::isSellableWithRoomType($product.id_product)) + || (Product::isSellableAsStandalone($product.id_product) && $product.standalone_total_qty > 0)} {include file="./cartrow.tpl" hotel_wise_data=false} {/if} {/if} diff --git a/themes/hotel-reservation-theme/modules/blockcart/cartrow.tpl b/themes/hotel-reservation-theme/modules/blockcart/cartrow.tpl index f7ce76c25..8a31e3b2f 100644 --- a/themes/hotel-reservation-theme/modules/blockcart/cartrow.tpl +++ b/themes/hotel-reservation-theme/modules/blockcart/cartrow.tpl @@ -55,7 +55,7 @@ {elseif $product.allow_multiple_quantity} {if isset($hotel_wise_data.id_hotel) && $hotel_wise_data.id_hotel} {$hotel_wise_data.total_qty} - {elseif Product::isSellableAsStandalone($product.selling_preference_type)} + {elseif Product::isSellableAsStandalone($product.id_product)} {$product.standalone_total_qty|intval} {/if} {/if} From fa775f81693a026b0ff63ce43f0666faf0b3acc2 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Fri, 29 May 2026 13:02:45 +0530 Subject: [PATCH 14/34] Refactor back office code by removing unused and redundant logic --- .../orders/_cart_booking_demands.tpl | 2 +- .../_add_order_extra_services_tab_content.tpl | 2 +- ..._extra_services_facilities_tab_content.tpl | 6 +- ..._services_service_products_tab_content.tpl | 6 +- classes/order/Order.php | 24 +-- controllers/admin/AdminCartsController.php | 58 ++++--- controllers/admin/AdminOrdersController.php | 152 +++++------------- 7 files changed, 86 insertions(+), 164 deletions(-) diff --git a/admin/themes/default/template/controllers/orders/_cart_booking_demands.tpl b/admin/themes/default/template/controllers/orders/_cart_booking_demands.tpl index bd695ea59..fad6ca46e 100644 --- a/admin/themes/default/template/controllers/orders/_cart_booking_demands.tpl +++ b/admin/themes/default/template/controllers/orders/_cart_booking_demands.tpl @@ -83,7 +83,7 @@ {if isset($selected_adv_option) && isset($demand['adv_option'][$selected_adv_option]['price_tax_excl'])}{convertPrice price = $demand['adv_option'][$selected_adv_option]['price_tax_excl']|escape:'html':'UTF-8'}{else if isset($demand['adv_option']) && $demand['adv_option']}{convertPrice price = $demand['adv_option'][$demand['adv_option']|@key]['price_tax_excl']}{else}{convertPrice price = $demand['price_tax_excl']|escape:'html':'UTF-8'}{/if} {if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY} - {l s='/ day'} + {l s='/ night'} {/if}
{displayPrice price=$demand['unit_price_tax_excl'] currency=$orderCurrency} {if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY} - {l s='/ day'} + {l s='/ night'} {/if} {displayPrice price=$demand['total_price_tax_excl'] currency=$orderCurrency} diff --git a/classes/order/Order.php b/classes/order/Order.php index 26ee52823..412f4460b 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -2882,27 +2882,13 @@ class OrderCore extends ObjectModel } // check hotel linked products $objServiceProductOrderDetail = new ServiceProductOrderDetail(); - $serviceProducts = array(); - $sellingPreferenceTypes = array( - Product::SELLING_PREFERENCE_HOTEL_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, - ); - foreach ($sellingPreferenceTypes as $sellingPreferenceType) { - $serviceProducts = array_merge( - $serviceProducts, - $objServiceProductOrderDetail->getServiceProductsInOrder($this->id, 0, 0, $sellingPreferenceType) - ); + if ($hotelProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($this->id, 0, 0, Product::SELLING_PREFERENCE_HOTEL_STANDALONE)) { + $res &= $this->checkList($hotelProducts, $action, false); + $hasRoomsOrProducts = 1; } - $serviceProducts = array_filter($serviceProducts, function ($serviceProduct) { - return empty($serviceProduct['id_htl_booking_detail']); - }); - if ($serviceProducts) { - $res &= $this->checkList($serviceProducts, $action, false); + if ($standaloneProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($this->id, 0, 0, Product::SELLING_PREFERENCE_STANDALONE)) { + $res &= $this->checkList($standaloneProducts, $action, false); $hasRoomsOrProducts = 1; } diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index 2b8115761..a30655767 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -354,12 +354,7 @@ class AdminCartsControllerCore extends AdminController $objServiceProductCartDetail = new ServiceProductCartDetail(); $hotelProducts = $objServiceProductCartDetail->getServiceProductsInCart( $cart->id, - [ - Product::SELLING_PREFERENCE_HOTEL_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE - ], + [], $idHotel = null, 0, null, @@ -373,14 +368,15 @@ class AdminCartsControllerCore extends AdminController 1 ); + $hotelProducts = array_filter($hotelProducts, function ($product) { + return $product['id_hotel'] > 0 && $product['id_hotel_cart_booking'] == 0; + }); + $standaloneProducts = $objServiceProductCartDetail->getServiceProductsInCart( $cart->id, - [ - Product::SELLING_PREFERENCE_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE - ] + [], + 0, + 0 ); if (count($standaloneProducts)) { @@ -1205,20 +1201,22 @@ class AdminCartsControllerCore extends AdminController if (Configuration::get('PS_ALLOW_ADD_ALL_SERVICES_IN_BOOKING')) { // get all services $objProduct = new Product(); - $serviceProducts = array_merge( - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE), - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE), - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE), - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE) - ); + $serviceProducts = array_values(array_filter( + $objProduct->getServiceProducts(null), + function ($serviceProduct) { + return Product::isSellableWithRoomType($serviceProduct['id_product']); + } + )); if ($serviceProducts) { foreach ($serviceProducts as $key => $servProduct) { + if (!Product::isAvailableWhenOutOfStock(StockAvailable::outOfStock((int)$servProduct['id_product'])) && Product::getQuantity((int)$servProduct['id_product']) <= 0 ) { unset($serviceProducts[$key]); continue; } + $numDays = Product::getPriceCalculationApplicableDays( $servProduct['price_calculation_method'], $dateFrom, @@ -1554,14 +1552,22 @@ class AdminCartsControllerCore extends AdminController if (Configuration::get('PS_ALLOW_ADD_ALL_SERVICES_IN_BOOKING')) { // get all services $objProduct = new Product(); - $serviceProducts = array_merge( - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE), - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE), - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE), - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE) - ); + $serviceProducts = array_values(array_filter( + $objProduct->getServiceProducts(null), + function ($serviceProduct) { + return Product::isSellableWithRoomType($serviceProduct['id_product']); + } + )); if ($serviceProducts) { foreach ($serviceProducts as $key => $servProduct) { + + if (!Product::isAvailableWhenOutOfStock(StockAvailable::outOfStock((int)$servProduct['id_product'])) + && Product::getQuantity((int)$servProduct['id_product']) <= 0 + ) { + unset($serviceProducts[$key]); + continue; + } + $numDays = Product::getPriceCalculationApplicableDays( $servProduct['price_calculation_method'], $objCartBookingData->date_from, @@ -1578,7 +1584,7 @@ class AdminCartsControllerCore extends AdminController $objCartBookingData->date_from, $objCartBookingData->date_to, $objCartBookingData->id_cart - )/$numDays; + )/ max($numDays, 1); } } } else { @@ -1742,7 +1748,7 @@ class AdminCartsControllerCore extends AdminController $idServiceProduct, $operator, $quantity, - false, + 0, $idCartBooking ))) { $originalPrice = Product::getPriceStatic($idServiceProduct, false); diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index fcf696f8a..d28c8fd23 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -992,12 +992,12 @@ class AdminOrdersControllerCore extends AdminController if (Configuration::get('PS_ALLOW_ADD_ALL_SERVICES_IN_BOOKING')) { // get all services $objProduct = new Product(); - $serviceProducts = array_merge( - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE), - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE), - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE), - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE) - ); + $serviceProducts = array_values(array_filter( + $objProduct->getServiceProducts(null), + function ($serviceProduct) { + return Product::isSellableWithRoomType($serviceProduct['id_product']); + } + )); if($serviceProducts) { foreach ($serviceProducts as $key => $servProduct) { @@ -1156,35 +1156,18 @@ class AdminOrdersControllerCore extends AdminController } $refundReqProducts = $objOrderReturn->getOrderRefundRequestedProducts($objOrder->id, 0, 1, 1); - $serviceProducts = array(); - $sellingPreferenceTypes = array( - Product::SELLING_PREFERENCE_HOTEL_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, - ); - foreach ($sellingPreferenceTypes as $sellingPreferenceType) { - $serviceProducts = array_merge( - $serviceProducts, - $objServiceProductOrderDetail->getServiceProductsInOrder($objOrder->id, 0, 0, $sellingPreferenceType) - ); - } - - $hotelProducts = array(); - $standaloneProducts = array(); - foreach ($serviceProducts as $product) { + $hotelProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($objOrder->id, 0, 0, Product::SELLING_PREFERENCE_HOTEL_STANDALONE); + foreach($hotelProducts as $key => $product) { if ((in_array($product['id_service_product_order_detail'], $refundReqProducts)) || $product['is_refunded']) { - continue; - } - if (!empty($product['id_hotel'])) { - $hotelProducts[] = $product; - } else if (!$product['id_hotel'] && !$product['id_htl_booking_detail']) { - $standaloneProducts[] = $product; + unset($hotelProducts[$key]); + } + } + $standaloneProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($objOrder->id, 0, 0, Product::SELLING_PREFERENCE_STANDALONE); + foreach($standaloneProducts as $key => $product) { + if ((in_array($product['id_service_product_order_detail'], $refundReqProducts)) || $product['is_refunded']) { + unset($standaloneProducts[$key]); } } - $this->context->smarty->assign( array( @@ -2454,20 +2437,8 @@ class AdminOrdersControllerCore extends AdminController } } - $hotelProducts = array(); - $hotelSellingTypes = array( - Product::SELLING_PREFERENCE_HOTEL_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, - ); - foreach ($hotelSellingTypes as $sellingPreferenceType) { - $hotelProducts = array_merge( - $hotelProducts, - $objRoomTypeServProdOrderDtl->getServiceProductsInOrder($order->id, 0, 0, $sellingPreferenceType) - ); - } - if ($hotelProducts && is_array($hotelProducts)) { + + if ($hotelProducts = $objRoomTypeServProdOrderDtl->getServiceProductsInOrder($order->id, 0, 0, Product::SELLING_PREFERENCE_HOTEL_STANDALONE)) { foreach ($hotelProducts as $serviceProduct) { $objRoomTypeServProdOrderDtl = new ServiceProductOrderDetail($serviceProduct['id_service_product_order_detail']); foreach ($fields as $field) { @@ -2481,20 +2452,8 @@ class AdminOrdersControllerCore extends AdminController $objRoomTypeServProdOrderDtl->save(); } } - $standaloneProducts = array(); - $standaloneSellingTypes = array( - Product::SELLING_PREFERENCE_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, - ); - foreach ($standaloneSellingTypes as $sellingPreferenceType) { - $standaloneProducts = array_merge( - $standaloneProducts, - $objRoomTypeServProdOrderDtl->getServiceProductsInOrder($order->id, 0, 0, $sellingPreferenceType) - ); - } - if ($standaloneProducts && is_array($standaloneProducts)) { + + if ($standaloneProducts = $objRoomTypeServProdOrderDtl->getServiceProductsInOrder($order->id, 0, 0, Product::SELLING_PREFERENCE_STANDALONE)) { foreach ($standaloneProducts as $serviceProduct) { $objRoomTypeServProdOrderDtl = new ServiceProductOrderDetail($serviceProduct['id_service_product_order_detail']); foreach ($fields as $field) { @@ -2988,30 +2947,9 @@ class AdminOrdersControllerCore extends AdminController // if order has normal products the add kpi for total products $objServiceProductOrderDetail = new ServiceProductOrderDetail(); - $serviceProducts = array(); - $sellingPreferenceTypes = array( - Product::SELLING_PREFERENCE_HOTEL_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, - ); - foreach ($sellingPreferenceTypes as $sellingPreferenceType) { - $serviceProducts = array_merge( - $serviceProducts, - $objServiceProductOrderDetail->getServiceProductsInOrder($objOrder->id, 0, 0, $sellingPreferenceType) - ); - } - $hotelProducts = array(); - $standaloneProducts = array(); - foreach ($serviceProducts as $serviceProduct) { - if (!empty($serviceProduct['id_hotel'])) { - $hotelProducts[] = $serviceProduct; - } else if (!$serviceProduct['id_hotel'] &&!$serviceProduct['id_htl_booking_detail']) { - $standaloneProducts[] = $serviceProduct; - } - } + $hotelProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($objOrder->id, 0, 0, Product::SELLING_PREFERENCE_HOTEL_STANDALONE); + $standaloneProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($objOrder->id, 0, 0, Product::SELLING_PREFERENCE_STANDALONE); + if ($hotelProducts || $standaloneProducts) { $helper = new HelperKpi(); $helper->id = 'box-total-products'; @@ -3357,16 +3295,16 @@ class AdminOrdersControllerCore extends AdminController } else { $product['image_link'] = $this->context->link->getImageLink($objProduct->link_rewrite, $this->context->language->iso_code.'-default', 'small_default'); } - if (Product::isSellableWithHotel($product['product_id']) - || Product::isSellableAsStandalone($product['product_id']) - ) { - $serviceProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($order->id, $product['id_order_detail'], $product['product_id']); - foreach ($serviceProducts as $serviceProduct) { - if (!empty($serviceProduct['id_hotel']) && Product::isSellableWithHotel($product['product_id'])) { - $orderHotelServiceProducts[] = array_merge($product, $serviceProduct); - } elseif (!$serviceProduct['id_hotel'] && !$serviceProduct['id_htl_booking_detail'] && Product::isSellableAsStandalone($product['product_id'])) { - $orderStandaloneServiceProducts[] = array_merge($product, $serviceProduct); - } + if ($product['selling_preference_type'] == Product::SELLING_PREFERENCE_HOTEL_STANDALONE) { + $hotelProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($order->id, $product['id_order_detail'], $product['product_id'], Product::SELLING_PREFERENCE_HOTEL_STANDALONE); + foreach ($hotelProducts as $hotelProduct) { + $orderHotelServiceProducts[] = array_merge($product, $hotelProduct); + } + } + if ($product['selling_preference_type'] == Product::SELLING_PREFERENCE_STANDALONE) { + $standaloneProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($order->id, $product['id_order_detail'], $product['product_id'], Product::SELLING_PREFERENCE_STANDALONE); + foreach ($standaloneProducts as $standaloneProduct) { + $orderStandaloneServiceProducts[] = array_merge($product, $standaloneProduct); } } } @@ -3698,17 +3636,9 @@ class AdminOrdersControllerCore extends AdminController // send hotel standalone and standalone products $objProduct = new Product(); - $allServiceProducts = $objProduct->getServiceProducts(null); - $hotelStandaloneProducts = array(); - $standaloneProducts = array(); - foreach ($allServiceProducts as $serviceProduct) { - if (Product::isSellableWithHotel($serviceProduct['id_product'])) { - $hotelStandaloneProducts[] = $serviceProduct; - } - if (Product::isSellableAsStandalone($serviceProduct['id_product'])) { - $standaloneProducts[] = $serviceProduct; - } - } + $hotelStandaloneProducts = $objProduct->getServiceProducts(null, Product::SELLING_PREFERENCE_HOTEL_STANDALONE); + $standaloneProducts = $objProduct->getServiceProducts(null, Product::SELLING_PREFERENCE_STANDALONE); + $this->tpl_view_vars = array( 'hotelStandaloneProducts' => $hotelStandaloneProducts, 'standaloneProducts' => $standaloneProducts, @@ -7502,12 +7432,12 @@ class AdminOrdersControllerCore extends AdminController if (Configuration::get('PS_ALLOW_ADD_ALL_SERVICES_IN_BOOKING')) { // get all services $objProduct = new Product(); - $serviceProducts = array_merge( - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE), - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE), - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE), - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE) - ); + $serviceProducts = array_values(array_filter( + $objProduct->getServiceProducts(null), + function ($serviceProduct) { + return Product::isSellableWithRoomType($serviceProduct['id_product']); + } + )); if ($serviceProducts) { foreach ($serviceProducts as $key => $servProduct) { if (!Product::isAvailableWhenOutOfStock(StockAvailable::outOfStock((int)$servProduct['id_product'])) From 71cd5573daa4c215a2aec43547a9a76279b08c43 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Fri, 29 May 2026 13:14:04 +0530 Subject: [PATCH 15/34] changes product const name --- .../normal_products/helpers/form/form.tpl | 2 +- .../normal_products/informations.tpl | 14 +-- .../controllers/normal_products/prices.tpl | 20 ++-- .../_add_order_extra_services_tab_content.tpl | 2 +- ..._services_service_products_tab_content.tpl | 6 +- classes/Cart.php | 2 +- classes/PaymentModule.php | 4 +- classes/Product.php | 100 +++++++++--------- classes/order/Order.php | 4 +- classes/order/OrderDetail.php | 4 +- .../WebserviceSpecificManagementBookings.php | 12 +-- config/defines.inc.php | 2 +- controllers/admin/AdminCartsController.php | 6 +- .../admin/AdminNormalProductsController.php | 32 +++--- controllers/admin/AdminOrdersController.php | 28 ++--- controllers/admin/AdminStatsController.php | 4 +- controllers/front/CartController.php | 2 +- controllers/front/ParentOrderController.php | 18 ++-- modules/blockcart/ajax-cart.js | 8 +- modules/blockcart/blockcart.tpl | 8 +- .../classes/HotelHelper.php | 12 +-- .../classes/ServiceProductCartDetail.php | 8 +- .../qlostatsserviceproducts.php | 8 +- .../_partials/cart_booking_demands.tpl | 2 +- .../_partials/service-products-list-row.tpl | 2 +- .../js/modules/blockcart/ajax-cart.js | 8 +- .../modules/blockcart/blockcart.tpl | 8 +- 27 files changed, 161 insertions(+), 165 deletions(-) diff --git a/admin/themes/default/template/controllers/normal_products/helpers/form/form.tpl b/admin/themes/default/template/controllers/normal_products/helpers/form/form.tpl index bc29f7e99..14b55a338 100644 --- a/admin/themes/default/template/controllers/normal_products/helpers/form/form.tpl +++ b/admin/themes/default/template/controllers/normal_products/helpers/form/form.tpl @@ -78,7 +78,7 @@ var SELLING_PREFERENCE_WITH_ROOM_TYPE = {Product::SELLING_PREFERENCE_WITH_ROOM_TYPE|intval}; var SELLING_PREFERENCE_HOTEL_STANDALONE = {Product::SELLING_PREFERENCE_HOTEL_STANDALONE|intval}; - var SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE = {Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE|intval}; + var SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE = {Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE|intval}; var SELLING_PREFERENCE_STANDALONE = {Product::SELLING_PREFERENCE_STANDALONE|intval}; var price_addition_type_with_room = {Product::PRICE_ADDITION_TYPE_WITH_ROOM|intval}; diff --git a/admin/themes/default/template/controllers/normal_products/informations.tpl b/admin/themes/default/template/controllers/normal_products/informations.tpl index a528df729..7dcd57e42 100644 --- a/admin/themes/default/template/controllers/normal_products/informations.tpl +++ b/admin/themes/default/template/controllers/normal_products/informations.tpl @@ -261,7 +261,7 @@ -
selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE)}style="display:none;"{/if}> +
selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE)}style="display:none;"{/if}>
{include file="controllers/products/multishop/checkbox.tpl" field="category_box" type="category_box"}
-
selling_preference_type != Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE && $product->selling_preference_type != 0)}style="display:none;"{/if}> +
selling_preference_type != Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE && $product->selling_preference_type != 0)}style="display:none;"{/if}>
{include file="controllers/products/multishop/checkbox.tpl" field="category_box" type="category_box"}
-
selling_preference_type != Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE && $product->selling_preference_type != 0}style="display:none;"{/if}> +
selling_preference_type != Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE && $product->selling_preference_type != 0}style="display:none;"{/if}>
{displayPrice price=$service['unit_price_tax_excl'] currency=$orderCurrency} - {if Product::getPriceCalculationApplicableDays( + {if Product::getServicePriceBillableDays( $service['price_calculation_method'], $additionalServices['date_from'], $additionalServices['date_to'] diff --git a/classes/Cart.php b/classes/Cart.php index 813ff4f89..242072486 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -2480,7 +2480,7 @@ class CartCore extends ObjectModel 'id_hotel_cart_booking' => $selectedProduct['id_hotel_cart_booking'], ); } - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $selectedProduct['price_calculation_method'], $selectedProduct['date_from'], $selectedProduct['date_to'] diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 8b6e57e1b..e289ad98a 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -592,7 +592,7 @@ abstract class PaymentModuleCore extends Module if (!$product['booking_product'] && ($product['selling_preference_type'] == Product::SELLING_PREFERENCE_STANDALONE || $product['selling_preference_type'] == Product::SELLING_PREFERENCE_HOTEL_STANDALONE - || $product['selling_preference_type'] == Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE + || $product['selling_preference_type'] == Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE ) ) { $cover_image_arr = $objProduct->getCover($product['id_product']); @@ -1065,7 +1065,7 @@ abstract class PaymentModuleCore extends Module } } - } elseif (Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE == $product['selling_preference_type']) { + } elseif (Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE == $product['selling_preference_type']) { $idProductRoomType = null; $idProductHotel = null; if (isset($product['id_room_type']) && $product['id_room_type']) { diff --git a/classes/Product.php b/classes/Product.php index 32c6d0bfe..8202e43d1 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -560,22 +560,22 @@ class ProductCore extends ObjectModel // Product selling preference types const SELLING_PREFERENCE_WITH_ROOM_TYPE = 1; // Product to be sold with Room types const SELLING_PREFERENCE_HOTEL_STANDALONE = 2; // Product to be sold Standalone with Hotels - const SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE = 3; // Product to be sold Standalone with Hotels and with Room types also + const SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE = 3; // Product to be sold Standalone with Hotels and with Room types also const SELLING_PREFERENCE_STANDALONE = 4; // Product to be sold standalone - const SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE = 5; // Product to be sold standalone and with Room types also - const SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE = 6; // Product to be sold standalone with Hotels and with Room types also - const SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE = 7; // Product to be sold standalone with Hotels and with Room types also and standalone + const SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE = 5; // Product to be sold standalone and with Room types also + const SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE = 6; // Product to be sold standalone with Hotels and with Room types also + const SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE = 7; // Product to be sold standalone with Hotels and with Room types also and standalone const PRICE_ADDITION_TYPE_WITH_ROOM = 1; const PRICE_ADDITION_TYPE_INDEPENDENT = 2; - const PRICE_CALCULATION_METHOD_ONLY_CHECKIN_DAY = 1; - const PRICE_CALCULATION_METHOD_ONLY_CHECKOUT_DAY = 2; - const PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY = 4; + const PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY = 1; + const PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY = 2; + const PRICE_CALCULATION_METHOD_ON_DURING_STAY = 4; const PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY = 3; - const PRICE_CALCULATION_METHOD_CHECKIN_AND_DURINGSTAY = 5; - const PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURINGSTAY = 6; - const PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY = 7; + const PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY = 5; + const PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY = 6; + const PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY = 7; const STANDARD_PRODUCT_ADDRESS_PREFERENCE_CUSTOMER = 1; const STANDARD_PRODUCT_ADDRESS_PREFERENCE_HOTEL = 2; @@ -1456,9 +1456,9 @@ class ProductCore extends ObjectModel '(`element_type` = '.RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE.' AND `id_element` = '.(int)$this->id.') ) AND (p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_WITH_ROOM_TYPE. ' - || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE.' - || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE.' - || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE.') + || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE.' + || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE.' + || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE.') AND product_shop.`id_shop` = '.(int)$context->shop->id .($sub_category? ' AND product_shop.`id_category_default` = '.(int)$sub_category : '') .($front ? ' AND product_shop.`show_at_front` = 1':'') @@ -1503,9 +1503,9 @@ class ProductCore extends ObjectModel '(`element_type` = '.RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE.' AND `id_element` = '.(int)$this->id.') ) AND (p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_WITH_ROOM_TYPE. ' - || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE.' - || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE.' - || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE.')'. ' + || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE.' + || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE.' + || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE.')'. ' AND product_shop.`id_shop` = '.(int)$context->shop->id .($sub_category? ' AND product_shop.`id_category_default` = '.(int)$sub_category : '') .($front ? ' AND product_shop.`show_at_front` = 1':'') @@ -1554,9 +1554,9 @@ class ProductCore extends ObjectModel '(`element_type` = '.RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE.' AND `id_element` = '.(int)$this->id.') ) AND p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_WITH_ROOM_TYPE. - ' || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE. - ' || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE. - ' || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE. + ' || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE. + ' || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE. + ' || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE. ' AND product_shop.`id_shop` = '.(int)$context->shop->id; $sql .= ' GROUP BY cl.`id_category`'; @@ -6881,7 +6881,7 @@ class ProductCore extends ObjectModel ) ); - $numdays = Product::getPriceCalculationApplicableDays( + $numdays = Product::getServicePriceBillableDays( Product::getProductPriceCalculation($idProduct), $dateFrom, $dateTo @@ -6892,46 +6892,42 @@ class ProductCore extends ObjectModel } - public static function getPriceCalculationApplicableDays( + public static function getServicePriceBillableDays( $priceCalculationMethod, $dateFrom, $dateTo, - $defaultDays = 1 ) { - if (empty($dateFrom) || empty($dateTo)) { - return (int) $defaultDays; - } $numNights = (int) HotelHelper::getNumberOfDays($dateFrom, $dateTo); - if ($numNights <= 0) { - return (int) $defaultDays; + if ($numNights < 1) { + return 1; } - $checkin = 1; - $checkout = 1; - $duringStay = max($numNights - 1, 0); + $checkinDay = 1; + $checkoutDay = 1; + $stayDay = $numNights - 1; switch ((int) $priceCalculationMethod) { - case self::PRICE_CALCULATION_METHOD_ONLY_CHECKIN_DAY: - return $checkin; + case self::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY: + return $checkinDay; - case self::PRICE_CALCULATION_METHOD_ONLY_CHECKOUT_DAY: - return $checkout; + case self::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY: + return $checkoutDay; - case self::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY: - return $duringStay; + case self::PRICE_CALCULATION_METHOD_ON_DURING_STAY: + return $stayDay; case self::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY: - return $checkin + $checkout; + return $checkinDay + $checkoutDay; - case self::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURINGSTAY: - return $checkin + $duringStay; + case self::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY: + return $checkinDay + $stayDay; - case self::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURINGSTAY: - return $checkout + $duringStay; + case self::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY: + return $checkoutDay + $stayDay; - case self::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY: - return $checkin + $checkout + $duringStay; + case self::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY: + return $checkinDay + $checkoutDay + $stayDay; default: return $numNights; @@ -6942,9 +6938,9 @@ class ProductCore extends ObjectModel { return in_array((int) self::getSellingPreferenceType($idProduct), [ self::SELLING_PREFERENCE_WITH_ROOM_TYPE, - self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - self::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, + self::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE, + self::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE, + self::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, ]); } @@ -6952,9 +6948,9 @@ class ProductCore extends ObjectModel { return in_array((int) self::getSellingPreferenceType($idProduct), [ self::SELLING_PREFERENCE_HOTEL_STANDALONE, - self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, + self::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE, + self::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE, + self::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, ]); } @@ -6962,9 +6958,9 @@ class ProductCore extends ObjectModel { return in_array((int) self::getSellingPreferenceType($idProduct), [ self::SELLING_PREFERENCE_STANDALONE, - self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - self::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, + self::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE, + self::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE, + self::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, ]); } } diff --git a/classes/order/Order.php b/classes/order/Order.php index 412f4460b..c3ed92715 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -2578,7 +2578,7 @@ class OrderCore extends ObjectModel )) { $totals = array_reduce($serviceProductDetail, function ($carry, $item) use ($order_detail) { $objHotelBookingDetail = new HotelBookingDetail((int) $item['id_htl_booking_detail']); - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $order_detail['product_price_calculation_method'], $objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to @@ -2633,7 +2633,7 @@ class OrderCore extends ObjectModel // We are getting auto added service for specific room.There will be only on htl_booking_detail but can have multiple auto added service with room. // Note: All the auto added service with room have same id_tax_rule group $autoAddedServiceData = array_shift($autoAddedServiceData); - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $order_detail['product_price_calculation_method'], $autoAddedServiceData['date_from'], $autoAddedServiceData['date_to'] diff --git a/classes/order/OrderDetail.php b/classes/order/OrderDetail.php index f9e165503..a5d0c2176 100644 --- a/classes/order/OrderDetail.php +++ b/classes/order/OrderDetail.php @@ -450,7 +450,7 @@ class OrderDetailCore extends ObjectModel $taxGroupInfo['id_room_type'], )) { $serviceProductData = array_shift($serviceProductData); - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $this->product_price_calculation_method, $serviceProductData['date_from'], $serviceProductData['date_to'] @@ -484,7 +484,7 @@ class OrderDetailCore extends ObjectModel $serviceProductData = array_shift($serviceProductData); $unit_price_tax_excl = isset($serviceProductData['unit_price_tax_excl']) ? $serviceProductData['unit_price_tax_excl'] : 0; - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $this->product_price_calculation_method, $serviceProductData['date_from'], $serviceProductData['date_to'] diff --git a/classes/webservice/WebserviceSpecificManagementBookings.php b/classes/webservice/WebserviceSpecificManagementBookings.php index b7c7546a8..960ab4521 100644 --- a/classes/webservice/WebserviceSpecificManagementBookings.php +++ b/classes/webservice/WebserviceSpecificManagementBookings.php @@ -1193,7 +1193,7 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We $objOrderDetail = new OrderDetail($service['id_order_detail']); $objServiceProductOrderDetail = new ServiceProductOrderDetail($service['id_service_product_order_detail']); $quantity = $objServiceProductOrderDetail->quantity; - $quantity *= Product::getPriceCalculationApplicableDays( + $quantity *= Product::getServicePriceBillableDays( $objOrderDetail->product_price_calculation_method, $objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to @@ -2312,7 +2312,7 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We foreach ($services as $service) { $insertedServiceProductIdOrderDetail = $objBookingDetail->getLastInsertedServiceIdOrderDetail($objOrder->id, $service['id_product']); - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( Product::getProductPriceCalculation($service['id_product']), $objBookingDetail->date_from, $objBookingDetail->date_to @@ -2670,7 +2670,7 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We foreach ($selectedAdditonalServices[$idHotelBooking]['additional_services'] as $service) { $serviceOrderDetail = new OrderDetail($service['id_order_detail']); $cart_quantity = $service['quantity']; - $serviceApplicableDays = Product::getPriceCalculationApplicableDays( + $serviceApplicableDays = Product::getServicePriceBillableDays( $service['price_calculation_method'], $dateFrom, $dateTo @@ -3189,7 +3189,7 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We $priceTaxExcl = $objServiceProductOrderDetail->total_price_tax_excl; $priceTaxIncl = $objServiceProductOrderDetail->total_price_tax_incl; $objHotelBookingDetail = new HotelBookingDetail($objServiceProductOrderDetail->id_htl_booking_detail); - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( Product::getProductPriceCalculation($service['id_product']), $objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to @@ -3285,7 +3285,7 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We $insertedServiceProductIdOrderDetail = $objHotelBookingDetail->getLastInsertedServiceIdOrderDetail($objOrder->id, $service['id_product']); $objOrderDetail = new OrderDetail($insertedServiceProductIdOrderDetail); - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( Product::getProductPriceCalculation($product['id_product']), $objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to @@ -4214,7 +4214,7 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We $services['id_service'] = (int) $service['id_product']; $services['name'] = $service['name']; $services['quantity'] = (int) $service['quantity']; - $applicableDays = Product::getPriceCalculationApplicableDays( + $applicableDays = Product::getServicePriceBillableDays( $service['price_calculation_method'], $additionalService['date_from'], $additionalService['date_to'] diff --git a/config/defines.inc.php b/config/defines.inc.php index f16e93903..d78f92763 100644 --- a/config/defines.inc.php +++ b/config/defines.inc.php @@ -26,7 +26,7 @@ /* Debug only */ if (!defined('_PS_MODE_DEV_')) { - define('_PS_MODE_DEV_', false); + define('_PS_MODE_DEV_', true); } /* Compatibility warning */ define('_PS_DISPLAY_COMPATIBILITY_WARNING_', false); diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index a30655767..2d22649ae 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -1217,7 +1217,7 @@ class AdminCartsControllerCore extends AdminController continue; } - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $servProduct['price_calculation_method'], $dateFrom, $dateTo @@ -1568,7 +1568,7 @@ class AdminCartsControllerCore extends AdminController continue; } - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $servProduct['price_calculation_method'], $objCartBookingData->date_from, $objCartBookingData->date_to @@ -1683,7 +1683,7 @@ class AdminCartsControllerCore extends AdminController $cartTotalQty = Cart::getProductQtyInCart($objCart->id, $idServiceProduct); $qty = (int)$serviceQuantities[$idServiceProduct]; - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $objProduct->price_calculation_method, $objHotelCartBookingData->date_from, $objHotelCartBookingData->date_to diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index 0c3986722..b41b5fd99 100644 --- a/controllers/admin/AdminNormalProductsController.php +++ b/controllers/admin/AdminNormalProductsController.php @@ -200,13 +200,13 @@ class AdminNormalProductsControllerCore extends AdminController Product::PRICE_ADDITION_TYPE_INDEPENDENT => $this->l('Convenience Fee') ); $priceCalculationMethod = array( - Product::PRICE_CALCULATION_METHOD_ONLY_CHECKIN_DAY => $this->l('Only check-in day'), - Product::PRICE_CALCULATION_METHOD_ONLY_CHECKOUT_DAY => $this->l('Only check-out day'), - Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY => $this->l('Only during-stay days'), + Product::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY => $this->l('Only check-in day'), + Product::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY => $this->l('Only check-out day'), + Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY => $this->l('Only during-stay days'), Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY => $this->l('Check-in and check-out days'), - Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURINGSTAY => $this->l('Check-in | during-stay days'), - Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURINGSTAY => $this->l('Check-out | during-stay days'), - Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY => $this->l('Check-in | check-out | during-stay days'), + Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY => $this->l('Check-in | during-stay days'), + Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY => $this->l('Check-out | during-stay days'), + Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY => $this->l('Check-in | check-out | during-stay days'), ); $this->_join .= ' @@ -331,12 +331,12 @@ class AdminNormalProductsControllerCore extends AdminController // Code For Standard product working $sellingPreferenceTypes = array( Product::SELLING_PREFERENCE_WITH_ROOM_TYPE => $this->l('With room type'), - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE => $this->l('With hotel|room type'), + Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE => $this->l('With hotel|room type'), Product::SELLING_PREFERENCE_STANDALONE => $this->l('Standalone'), Product::SELLING_PREFERENCE_HOTEL_STANDALONE => $this->l('With hotel'), - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE => $this->l('With hotel|standalone'), - Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE => $this->l('With room type|standalone'), - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE => $this->l('With hotel|room type|standalone'), + Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE => $this->l('With hotel|standalone'), + Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE => $this->l('With room type|standalone'), + Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE => $this->l('With hotel|room type|standalone'), ); $this->fields_list['selling_preference_type'] = array( 'type' => 'select', @@ -3016,15 +3016,15 @@ class AdminNormalProductsControllerCore extends AdminController $roomTypeSellingPreferences = array( Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, + Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE, + Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE, + Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, ); $hotelSellingPreferences = array( Product::SELLING_PREFERENCE_HOTEL_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, + Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE, + Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE, + Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, ); if (in_array((int)$product->selling_preference_type, $roomTypeSellingPreferences, true)) { diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index d28c8fd23..a824685d0 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -1013,7 +1013,7 @@ class AdminOrdersControllerCore extends AdminController unset($serviceProducts[$key]); } else { - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $servProduct['price_calculation_method'], $dateFrom, $dateTo @@ -4184,9 +4184,9 @@ class AdminOrdersControllerCore extends AdminController $products = array(); $standaloneSellingPreferenceTypes = array( Product::SELLING_PREFERENCE_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, + Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE, + Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE, + Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, ); foreach ($standaloneSellingPreferenceTypes as $sellingPreferenceType) { if ($productsByType = Product::searchByName( @@ -5396,7 +5396,7 @@ class AdminOrdersControllerCore extends AdminController )) { foreach ($services as $service) { $insertedServiceProductIdOrderDetail = $objBookingDetail->getLastInsertedServiceIdOrderDetail($order->id, $service['id_product']); - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( Product::getProductPriceCalculation($service['id_product']), $objBookingDetail->date_from, $objBookingDetail->date_to @@ -6197,12 +6197,12 @@ class AdminOrdersControllerCore extends AdminController && count($orderServiceProduct['additional_services']) ) { foreach ($orderServiceProduct['additional_services'] as $serviceProduct) { - $newNumDays = Product::getPriceCalculationApplicableDays( + $newNumDays = Product::getServicePriceBillableDays( $serviceProduct['price_calculation_method'], $new_date_from, $new_date_to ); - $oldNumDays = Product::getPriceCalculationApplicableDays( + $oldNumDays = Product::getServicePriceBillableDays( $serviceProduct['price_calculation_method'], $old_date_from, $old_date_to @@ -6589,7 +6589,7 @@ class AdminOrdersControllerCore extends AdminController $serviceOrderDetail = new OrderDetail($service['id_order_detail']); $cart_quantity = $service['quantity']; - $serviceApplicableDays = Product::getPriceCalculationApplicableDays( + $serviceApplicableDays = Product::getServicePriceBillableDays( $service['price_calculation_method'], $selectedAdditonalServices[$idHotelBooking]['date_from'], $selectedAdditonalServices[$idHotelBooking]['date_to'] @@ -7452,7 +7452,7 @@ class AdminOrdersControllerCore extends AdminController unset($serviceProducts[$key]); } else { - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $servProduct['price_calculation_method'], $dateFrom, $dateTo @@ -7637,7 +7637,7 @@ class AdminOrdersControllerCore extends AdminController $objServiceProductOrderDetail->quantity = $quantity; $objServiceProductOrderDetail->unit_price_tax_excl = $unitPrice; $objServiceProductOrderDetail->unit_price_tax_incl = $unitPrice * $oldTaxMultiplier; - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $objOrderDetail->product_price_calculation_method, $objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to @@ -7757,7 +7757,7 @@ class AdminOrdersControllerCore extends AdminController if ($objProduct->allow_multiple_quantity && Validate::isUnsignedInt($qty[$service])) { $finalQty = (int)$qty[$service]; - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( Product::getProductPriceCalculation($service), $objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to @@ -7813,7 +7813,7 @@ class AdminOrdersControllerCore extends AdminController $this->context->cart = $cart; $this->context->customer = new Customer($order->id_customer); - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( Product::getProductPriceCalculation($service['id']), $objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to @@ -8133,7 +8133,7 @@ class AdminOrdersControllerCore extends AdminController $objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice(); $cartProductProcessed = 1; - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( Product::getProductPriceCalculation($objServiceProduct->id), $objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to @@ -8369,7 +8369,7 @@ class AdminOrdersControllerCore extends AdminController if ($res &= $objServiceProductOrderDetail->delete()) { $order = new Order($objServiceProductOrderDetail->id_order); - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $objOrderDetail->product_price_calculation_method, $objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to diff --git a/controllers/admin/AdminStatsController.php b/controllers/admin/AdminStatsController.php index 9886d86a1..0ade4a0e5 100644 --- a/controllers/admin/AdminStatsController.php +++ b/controllers/admin/AdminStatsController.php @@ -2421,9 +2421,9 @@ class AdminStatsControllerCore extends AdminStatsTabController IFNULL(SUM( CASE WHEN od.`purchase_supplier_price` <> "0.000000" - THEN (od.`purchase_supplier_price` / (IF (od.`product_price_calculation_method` = '.Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY.', DATEDIFF(hbd.`date_to`, hbd.`date_from`), 1))) + THEN (od.`purchase_supplier_price` / (IF (od.`product_price_calculation_method` = '.Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY.', DATEDIFF(hbd.`date_to`, hbd.`date_from`), 1))) WHEN od.`purchase_supplier_price` = "0.000000" - THEN ((od.`original_product_price` / o.`conversion_rate`) * '.(int)Configuration::get('CONF_AVERAGE_PRODUCT_MARGIN').' / 100) / (IF (od.`product_price_calculation_method` = '.Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY.', DATEDIFF(hbd.`date_to`, hbd.`date_from`), 1)) + THEN ((od.`original_product_price` / o.`conversion_rate`) * '.(int)Configuration::get('CONF_AVERAGE_PRODUCT_MARGIN').' / 100) / (IF (od.`product_price_calculation_method` = '.Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY.', DATEDIFF(hbd.`date_to`, hbd.`date_from`), 1)) END ), 0) FROM `'._DB_PREFIX_.'service_product_order_detail` rtspod diff --git a/controllers/front/CartController.php b/controllers/front/CartController.php index 10df365a1..8e1937270 100644 --- a/controllers/front/CartController.php +++ b/controllers/front/CartController.php @@ -756,7 +756,7 @@ class CartControllerCore extends FrontController $this->errors[] = Tools::displayError('The quantity you\'ve entered is invalid.'); } else { $cartTotalQty = Cart::getProductQtyInCart((int)$this->context->cart->id,(int)$idServiceProduct); - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $objProduct->price_calculation_method, $objHotelCartBookingData->date_from, $objHotelCartBookingData->date_to diff --git a/controllers/front/ParentOrderController.php b/controllers/front/ParentOrderController.php index 573aea7f8..6048edfdc 100644 --- a/controllers/front/ParentOrderController.php +++ b/controllers/front/ParentOrderController.php @@ -324,9 +324,9 @@ class ParentOrderControllerCore extends FrontController $objServiceProductCartDetail = new ServiceProductCartDetail(); $hotelSellingPreferences = [ Product::SELLING_PREFERENCE_HOTEL_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, + Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE, + Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE, + Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, ]; if ($hotelProducts = $objServiceProductCartDetail->getServiceProductsInCart( $this->context->cart->id, @@ -353,9 +353,9 @@ class ParentOrderControllerCore extends FrontController $standaloneSellingPreferences = [ Product::SELLING_PREFERENCE_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, + Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE, + Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE, + Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, ]; $standaloneProducts = $objServiceProductCartDetail->getServiceProductsInCart( $this->context->cart->id, @@ -501,9 +501,9 @@ class ParentOrderControllerCore extends FrontController $objServiceProductCartDetail = new ServiceProductCartDetail(); $standaloneSellingPreferences = [ Product::SELLING_PREFERENCE_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, + Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE, + Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE, + Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, ]; if (count($objServiceProductCartDetail->getServiceProductsInCart( $this->context->cart->id, diff --git a/modules/blockcart/ajax-cart.js b/modules/blockcart/ajax-cart.js index fccec2e4f..10b8df061 100644 --- a/modules/blockcart/ajax-cart.js +++ b/modules/blockcart/ajax-cart.js @@ -140,22 +140,22 @@ var ajaxCart = { case SELLING_PREFERENCE_HOTEL_STANDALONE: channels.with_hotel = true; break; - case SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE: + case SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE: channels.with_room_type = true; channels.with_hotel = true; break; case SELLING_PREFERENCE_STANDALONE: channels.standalone = true; break; - case SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE: + case SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE: channels.with_hotel = true; channels.standalone = true; break; - case SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE: + case SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE: channels.with_room_type = true; channels.standalone = true; break; - case SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE: + case SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE: channels.with_room_type = true; channels.with_hotel = true; channels.standalone = true; diff --git a/modules/blockcart/blockcart.tpl b/modules/blockcart/blockcart.tpl index 6caf931e7..910a50f4a 100644 --- a/modules/blockcart/blockcart.tpl +++ b/modules/blockcart/blockcart.tpl @@ -405,10 +405,10 @@ {addJsDef SELLING_PREFERENCE_WITH_ROOM_TYPE=Product::SELLING_PREFERENCE_WITH_ROOM_TYPE} {addJsDef SELLING_PREFERENCE_STANDALONE=Product::SELLING_PREFERENCE_STANDALONE} {addJsDef SELLING_PREFERENCE_HOTEL_STANDALONE=Product::SELLING_PREFERENCE_HOTEL_STANDALONE} - {addJsDef SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE=Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE} - {addJsDef SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE=Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE} - {addJsDef SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE=Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE} - {addJsDef SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE=Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE} + {addJsDef SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE=Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE} + {addJsDef SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE=Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE} + {addJsDef SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE=Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE} + {addJsDef SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE=Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE} {addJsDefL name=customizationIdMessage}{l s='Customization #' mod='blockcart' js=1}{/addJsDefL} {addJsDefL name=removingLinkText}{l s='remove this product from my cart' mod='blockcart' js=1}{/addJsDefL} diff --git a/modules/hotelreservationsystem/classes/HotelHelper.php b/modules/hotelreservationsystem/classes/HotelHelper.php index 2cb844209..b8bea902b 100644 --- a/modules/hotelreservationsystem/classes/HotelHelper.php +++ b/modules/hotelreservationsystem/classes/HotelHelper.php @@ -2155,7 +2155,7 @@ class HotelHelper 'price' => '250', 'auto_add_to_cart' => 1, 'show_at_front' => 0, - 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY, + 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY, 'price_addition_type' => Product::PRICE_ADDITION_TYPE_WITH_ROOM, 'en' => array( 'name' => 'Room Maintenance Fees', @@ -2187,7 +2187,7 @@ class HotelHelper 'price' => '250', 'auto_add_to_cart' => 1, 'show_at_front' => 0, - 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY, + 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY, 'price_addition_type' => Product::PRICE_ADDITION_TYPE_INDEPENDENT, 'en' => array( 'name' => 'Internet Handling Charges', @@ -2220,7 +2220,7 @@ class HotelHelper 'price' => '50', 'auto_add_to_cart' => 0, 'show_at_front' => 1, - 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY, + 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY, 'price_addition_type' => Product::PRICE_ADDITION_TYPE_WITH_ROOM, 'en' => array( 'name' => 'Airport Shuttle', @@ -2252,7 +2252,7 @@ class HotelHelper 'price' => '200', 'auto_add_to_cart' => 0, 'show_at_front' => 1, - 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY, + 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY, 'price_addition_type' => Product::PRICE_ADDITION_TYPE_WITH_ROOM, 'en' => array( 'name' => 'Cab on Demand', @@ -2284,7 +2284,7 @@ class HotelHelper 'price' => '350', 'auto_add_to_cart' => 0, 'show_at_front' => 1, - 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY, + 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY, 'price_addition_type' => Product::PRICE_ADDITION_TYPE_WITH_ROOM, 'en' => array( 'name' => 'Breakfast', @@ -2316,7 +2316,7 @@ class HotelHelper 'price' => '450', 'auto_add_to_cart' => 0, 'show_at_front' => 1, - 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY, + 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY, 'price_addition_type' => Product::PRICE_ADDITION_TYPE_WITH_ROOM, 'en' => array( 'name' => 'Dinner', diff --git a/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php b/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php index 512e12b6b..a7872d9a8 100644 --- a/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php +++ b/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php @@ -90,7 +90,7 @@ class ServiceProductCartDetail extends ObjectModel )) { $updateQty = $product['quantity']; $objHotelCartBookingData = new HotelCartBookingData($htlCartBookingId); - $numdays = Product::getPriceCalculationApplicableDays( + $numdays = Product::getServicePriceBillableDays( Product::getProductPriceCalculation($product['id_product']), $objHotelCartBookingData->date_from, $objHotelCartBookingData->date_to @@ -251,7 +251,7 @@ class ServiceProductCartDetail extends ObjectModel $product['htl_cart_booking_id'] ); } else { - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $objProduct->price_calculation_method, $product['date_from'], $product['date_to'] @@ -458,7 +458,7 @@ class ServiceProductCartDetail extends ObjectModel if ($objServiceProductCartDetail->save()) { if (Validate::isLoadedObject($objHotelCartBooking = new HotelCartBookingData($idHtlCartData))) { - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $objProduct->price_calculation_method, $objHotelCartBooking->date_from, $objHotelCartBooking->date_to @@ -520,7 +520,7 @@ class ServiceProductCartDetail extends ObjectModel if ($updateQunatity) { if (Validate::isLoadedObject($objHotelCartBooking = new HotelCartBookingData($product['id_hotel_cart_booking']))) { $objProduct = new Product((int) $product['id_product']); - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $objProduct->price_calculation_method, $objHotelCartBooking->date_from, $objHotelCartBooking->date_to diff --git a/modules/qlostatsserviceproducts/qlostatsserviceproducts.php b/modules/qlostatsserviceproducts/qlostatsserviceproducts.php index 684cf15f9..c36687ef1 100644 --- a/modules/qlostatsserviceproducts/qlostatsserviceproducts.php +++ b/modules/qlostatsserviceproducts/qlostatsserviceproducts.php @@ -182,11 +182,11 @@ class QloStatsServiceProducts extends ModuleGrid $numNightsSql = 'IFNULL(DATEDIFF(hbd.`date_to`, hbd.`date_from`), 0)'; $applicableDaysSql = 'CASE WHEN spod.`id_htl_booking_detail` IS NULL OR spod.`id_htl_booking_detail` = 0 THEN 1 - WHEN od.`product_price_calculation_method` IN ('.(int)Product::PRICE_CALCULATION_METHOD_ONLY_CHECKIN_DAY.', '.(int)Product::PRICE_CALCULATION_METHOD_ONLY_CHECKOUT_DAY.') THEN 1 - WHEN od.`product_price_calculation_method` = '.(int)Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY.' THEN GREATEST('.$numNightsSql.' - 1, 1) + WHEN od.`product_price_calculation_method` IN ('.(int)Product::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY.', '.(int)Product::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY.') THEN 1 + WHEN od.`product_price_calculation_method` = '.(int)Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY.' THEN GREATEST('.$numNightsSql.' - 1, 1) WHEN od.`product_price_calculation_method` = '.(int)Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY.' THEN 2 - WHEN od.`product_price_calculation_method` IN ('.(int)Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURINGSTAY.', '.(int)Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURINGSTAY.') THEN GREATEST('.$numNightsSql.', 1) - WHEN od.`product_price_calculation_method` = '.(int)Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY.' THEN GREATEST('.$numNightsSql.' + 1, 1) + WHEN od.`product_price_calculation_method` IN ('.(int)Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY.', '.(int)Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY.') THEN GREATEST('.$numNightsSql.', 1) + WHEN od.`product_price_calculation_method` = '.(int)Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY.' THEN GREATEST('.$numNightsSql.' + 1, 1) ELSE GREATEST('.$numNightsSql.', 1) END'; diff --git a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl index 7f218e0c8..964cba5d8 100644 --- a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl +++ b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl @@ -153,7 +153,7 @@ {if ($product.show_price && !isset($restricted_country_mode)) || isset($groups)} {if !$priceDisplay}{convertPrice price=$product.price_tax_incl}{else}{convertPrice price=$product.price_tax_exc}{/if} - {if Product::getPriceCalculationApplicableDays( + {if Product::getServicePriceBillableDays( $product.price_calculation_method, $cartRoom.date_from|default:'', $cartRoom.date_to|default:'' diff --git a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl index 8df8fe516..c636e4129 100644 --- a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl +++ b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl @@ -55,7 +55,7 @@
{block name='service_product_price'} {if !$priceDisplay}{convertPrice price=$service_product.price_tax_incl}{else}{convertPrice price=$service_product.price_tax_exc}{/if} - {if Product::getPriceCalculationApplicableDays( + {if Product::getServicePriceBillableDays( $service_product.price_calculation_method, $service_product.date_from|default:$date_from|default:'', $service_product.date_to|default:$date_to|default:'' 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 51978e8fe..7c2fa5f05 100644 --- a/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js +++ b/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js @@ -140,22 +140,22 @@ var ajaxCart = { case SELLING_PREFERENCE_HOTEL_STANDALONE: channels.with_hotel = true; break; - case SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE: + case SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE: channels.with_room_type = true; channels.with_hotel = true; break; case SELLING_PREFERENCE_STANDALONE: channels.standalone = true; break; - case SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE: + case SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE: channels.with_hotel = true; channels.standalone = true; break; - case SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE: + case SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE: channels.with_room_type = true; channels.standalone = true; break; - case SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE: + case SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE: channels.with_room_type = true; channels.with_hotel = true; channels.standalone = true; diff --git a/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl b/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl index 47121ca96..fecff84c9 100644 --- a/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl +++ b/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl @@ -406,10 +406,10 @@ {addJsDef SELLING_PREFERENCE_WITH_ROOM_TYPE=Product::SELLING_PREFERENCE_WITH_ROOM_TYPE} {addJsDef SELLING_PREFERENCE_STANDALONE=Product::SELLING_PREFERENCE_STANDALONE} {addJsDef SELLING_PREFERENCE_HOTEL_STANDALONE=Product::SELLING_PREFERENCE_HOTEL_STANDALONE} - {addJsDef SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE=Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE} - {addJsDef SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE=Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE} - {addJsDef SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE=Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE} - {addJsDef SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE=Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE} + {addJsDef SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE=Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE} + {addJsDef SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE=Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE} + {addJsDef SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE=Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE} + {addJsDef SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE=Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE} {addJsDefL name=customizationIdMessage}{l s='Customization #' mod='blockcart' js=1}{/addJsDefL} {addJsDefL name=removingLinkText}{l s='remove this product from my cart' mod='blockcart' js=1}{/addJsDefL} From 412f43919b01bbc8ee590f05f3d40ef48ed5c604 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Fri, 29 May 2026 19:12:37 +0530 Subject: [PATCH 16/34] Fix: Incorrect selling type context during order validation for multi-preference service products --- .../normal_products/helpers/form/form.tpl | 6 +- .../normal_products/informations.tpl | 14 ++-- .../controllers/orders/helpers/view/view.tpl | 4 +- classes/Cart.php | 45 +++++------ classes/PaymentModule.php | 22 +++--- classes/Product.php | 36 ++++----- classes/order/Order.php | 4 +- classes/order/OrderInvoice.php | 4 +- classes/pdf/HTMLTemplateInvoice.php | 8 +- classes/pdf/HTMLTemplateOrderSlip.php | 4 +- .../WebserviceSpecificManagementBookings.php | 2 +- config/defines.inc.php | 2 +- .../admin/AdminNormalProductsController.php | 18 ++--- controllers/admin/AdminOrdersController.php | 32 ++++---- controllers/front/GuestTrackingController.php | 4 +- .../front/OrderConfirmationController.php | 8 +- controllers/front/OrderDetailController.php | 4 +- controllers/front/ParentOrderController.php | 14 ++-- js/admin/normal_products.js | 4 +- modules/blockcart/ajax-cart.js | 54 ++++---------- modules/blockcart/blockcart.tpl | 8 +- .../AdminHotelRoomsBookingController.php | 4 +- .../_partials/cart_booking_demands.tpl | 28 ++++++- ...e-calculation-info.tpl => htl-tooltip.tpl} | 24 ++---- .../_partials/order-extra-services.tpl | 28 ++++++- .../_partials/order-room-detail.tpl | 56 +++++++------- .../_partials/service-products-list-row.tpl | 28 ++++++- themes/hotel-reservation-theme/css/global.css | 67 ++++++++++------- themes/hotel-reservation-theme/js/global.js | 67 ++++++++--------- .../js/modules/blockcart/ajax-cart.js | 54 ++++---------- .../js/order-confirmation.js | 41 +--------- .../js/order-detail.js | 74 +------------------ .../hotel-reservation-theme/js/order-opc.js | 41 +--------- themes/hotel-reservation-theme/js/product.js | 2 +- .../modules/blockcart/blockcart.tpl | 8 +- .../order-confirmation.tpl | 56 +++++++------- .../hotel-reservation-theme/order-detail.tpl | 12 +-- .../shopping-cart-detail.tpl | 22 +++--- 38 files changed, 387 insertions(+), 522 deletions(-) rename themes/hotel-reservation-theme/_partials/{price-calculation-info.tpl => htl-tooltip.tpl} (59%) diff --git a/admin/themes/default/template/controllers/normal_products/helpers/form/form.tpl b/admin/themes/default/template/controllers/normal_products/helpers/form/form.tpl index 14b55a338..d1b79abc2 100644 --- a/admin/themes/default/template/controllers/normal_products/helpers/form/form.tpl +++ b/admin/themes/default/template/controllers/normal_products/helpers/form/form.tpl @@ -77,9 +77,9 @@ var product_type_simple = {Product::PTYPE_SIMPLE|intval}; var SELLING_PREFERENCE_WITH_ROOM_TYPE = {Product::SELLING_PREFERENCE_WITH_ROOM_TYPE|intval}; - var SELLING_PREFERENCE_HOTEL_STANDALONE = {Product::SELLING_PREFERENCE_HOTEL_STANDALONE|intval}; - var SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE = {Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE|intval}; - var SELLING_PREFERENCE_STANDALONE = {Product::SELLING_PREFERENCE_STANDALONE|intval}; + var SELLING_PREFERENCE_WITH_HOTEL = {Product::SELLING_PREFERENCE_WITH_HOTEL|intval}; + var SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE = {Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE|intval}; + var SELLING_PREFERENCE_WITH_STANDALONE = {Product::SELLING_PREFERENCE_WITH_STANDALONE|intval}; var price_addition_type_with_room = {Product::PRICE_ADDITION_TYPE_WITH_ROOM|intval}; var price_addition_type_independent = {Product::PRICE_ADDITION_TYPE_INDEPENDENT|intval}; diff --git a/admin/themes/default/template/controllers/normal_products/informations.tpl b/admin/themes/default/template/controllers/normal_products/informations.tpl index 7dcd57e42..3437c1d03 100644 --- a/admin/themes/default/template/controllers/normal_products/informations.tpl +++ b/admin/themes/default/template/controllers/normal_products/informations.tpl @@ -261,7 +261,7 @@
-
selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE)}style="display:none;"{/if}> +
selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTEL && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE)}style="display:none;"{/if}>
{include file="controllers/products/multishop/checkbox.tpl" field="category_box" type="category_box"}
-
selling_preference_type != Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE && $product->selling_preference_type != 0)}style="display:none;"{/if}> +
selling_preference_type != Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE && $product->selling_preference_type != 0)}style="display:none;"{/if}>
{include file="controllers/products/multishop/checkbox.tpl" field="category_box" type="category_box"}
-
selling_preference_type != Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE && $product->selling_preference_type != 0}style="display:none;"{/if}> +
selling_preference_type != Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE && $product->selling_preference_type != 0}style="display:none;"{/if}>
{$product['name']|escape:'html':'UTF-8'} - {include file='_partials/price-calculation-info.tpl' pcm=$product.price_calculation_method|default:0} + {assign var='priceCalcMethod' value=$product.price_calculation_method|default:0} + {capture name='htl_pcm_tooltip'} +
+

{l s='Applied on:'}

+
    + {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} +
  • {l s='Check-in day'}
  • + {/if} + {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} +
  • {l s='During-stay days'}
  • + {/if} + {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} +
  • {l s='Check-out day'}
  • + {/if} +
+
+ {/capture} + {include file='_partials/htl-tooltip.tpl' tooltip_content=$smarty.capture.htl_pcm_tooltip allow_html=true} {if $product.allow_multiple_quantity}
diff --git a/themes/hotel-reservation-theme/_partials/price-calculation-info.tpl b/themes/hotel-reservation-theme/_partials/htl-tooltip.tpl similarity index 59% rename from themes/hotel-reservation-theme/_partials/price-calculation-info.tpl rename to themes/hotel-reservation-theme/_partials/htl-tooltip.tpl index af5f05850..997e93fa7 100644 --- a/themes/hotel-reservation-theme/_partials/price-calculation-info.tpl +++ b/themes/hotel-reservation-theme/_partials/htl-tooltip.tpl @@ -20,24 +20,14 @@ * @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0 *} -{* Required param: pcm — price_calculation_method integer value *} - + -
diff --git a/themes/hotel-reservation-theme/_partials/order-room-detail.tpl b/themes/hotel-reservation-theme/_partials/order-room-detail.tpl index aaf47aa0c..35f3ac7c9 100644 --- a/themes/hotel-reservation-theme/_partials/order-room-detail.tpl +++ b/themes/hotel-reservation-theme/_partials/order-room-detail.tpl @@ -125,41 +125,35 @@ {displayWtPriceWithCurrency price=($rm_v.amount_tax_excl + $rm_v.extra_demands_price_te + $rm_v.additional_services_price_te + $rm_v.additional_services_price_auto_add_te) currency=$currency} {/if} {if (isset($rm_v.extra_demands) && $rm_v.extra_demands) || isset($rm_v.additional_services) && $rm_v.additional_services} - - - -
{l s='Total rooms cost'} {if $use_taxes && $display_tax_label == 1}{if $priceDisplay == 1}{l s='(tax excl.)'}{elseif $priceDisplay == 0}{l s='(tax incl.)'}{/if} {/if}
{$product['name']|escape:'html':'UTF-8'} - {include file='controllers/orders/modals/_partials/_price-calculation-info.tpl' pcm=$product['price_calculation_method']|default:0} + {capture name='room_type_service_tooltip_content'} + {assign var="priceCalcMethod" value=$product['price_calculation_method']|default:0} +
+
+
    + {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} +
  • {l s='Check-in day'}
  • + {/if} + {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} +
  • {l s='During-stay days'}
  • + {/if} + {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} +
  • {l s='Check-out day'}
  • + {/if} +
+
+ {/capture} + + {include file='helpers/tooltip.tpl' tooltip_content=$smarty.capture.room_type_service_tooltip_content allow_html=true}
diff --git a/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl b/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl index 65d1c2344..f98d22808 100644 --- a/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl +++ b/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl @@ -55,6 +55,35 @@
{$service['name']|escape:'html':'UTF-8'} + {capture name='room_type_service_tooltip_content'} + {assign var="priceCalcMethod" value=$service['price_calculation_method']|default:0} +
+
+
    + {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} +
  • {l s='Check-in day'}
  • + {/if} + {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} +
  • {l s='During-stay days'}
  • + {/if} + {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} +
  • {l s='Check-out day'}
  • + {/if} +
+
+ {/capture} + + {include file='helpers/tooltip.tpl' tooltip_content=$smarty.capture.room_type_service_tooltip_content allow_html=true} +
{$product['name']|escape:'html':'UTF-8'} - {include file='controllers/orders/modals/_partials/_price-calculation-info.tpl' pcm=$product['price_calculation_method']|default:0} - {if $product['auto_add_to_cart'] && $product['price_addition_type'] == Product::PRICE_ADDITION_TYPE_WITH_ROOM} {l s='Auto added'}
@@ -296,8 +351,33 @@
{$service['name']|escape:'html':'UTF-8'} - {include file='controllers/orders/modals/_partials/_price-calculation-info.tpl' pcm=$service.price_calculation_method|default:0} - {if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT} {l s='Convenience fee'} diff --git a/admin/themes/default/template/controllers/orders/modals/_partials/_price-calculation-info.tpl b/admin/themes/default/template/controllers/orders/modals/_partials/_price-calculation-info.tpl deleted file mode 100644 index 00ad669f5..000000000 --- a/admin/themes/default/template/controllers/orders/modals/_partials/_price-calculation-info.tpl +++ /dev/null @@ -1,43 +0,0 @@ -{* -* NOTICE OF LICENSE -* -* This source file is subject to the Open Software License version 3.0 -* that is bundled with this package in the file LICENSE.md -* It is also available through the world-wide-web at this URL: -* https://opensource.org/license/osl-3-0-php -* If you did not receive a copy of the license and are unable to -* obtain it through the world-wide-web, please send an email -* to support@qloapps.com so we can send you a copy immediately. -* -* DISCLAIMER -* -* Do not edit or add to this file if you wish to upgrade this module to a newer -* versions in the future. If you wish to customize this module for your needs -* please refer to https://store.webkul.com/customisation-guidelines for more information. -* -* @author Webkul IN -* @copyright Since 2010 Webkul -* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0 -*} - -{* Required param: pcm — price_calculation_method integer value *} - - - - - diff --git a/admin/themes/default/template/controllers/normal_products/selected_option.tpl b/admin/themes/default/template/helpers/tooltip.tpl similarity index 59% rename from admin/themes/default/template/controllers/normal_products/selected_option.tpl rename to admin/themes/default/template/helpers/tooltip.tpl index 24156a9e1..8d38c8982 100644 --- a/admin/themes/default/template/controllers/normal_products/selected_option.tpl +++ b/admin/themes/default/template/helpers/tooltip.tpl @@ -21,13 +21,20 @@ *} -{capture name='options_list'} -
    - {foreach $selected_options as $opt} -
  • {$opt|escape:'html'}
  • - {/foreach} -
-{/capture} - - {$selected_options|@count} Selected + + + + diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index 8978f4662..a9723fccc 100644 --- a/controllers/admin/AdminNormalProductsController.php +++ b/controllers/admin/AdminNormalProductsController.php @@ -200,13 +200,13 @@ class AdminNormalProductsControllerCore extends AdminController Product::PRICE_ADDITION_TYPE_INDEPENDENT => $this->l('Convenience Fee') ); $priceCalculationMethod = array( - Product::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY => $this->l('Only check-in day'), - Product::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY => $this->l('Only check-out day'), - Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY => $this->l('Only during-stay days'), - Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY => $this->l('Check-in and check-out days'), - Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY => $this->l('Check-in | during-stay days'), - Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY => $this->l('Check-out | during-stay days'), - Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY => $this->l('Check-in | check-out | during-stay days'), + Product::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY => $this->l('On Check-in day'), + Product::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY => $this->l('On Check-out day'), + Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY => $this->l('On During-stay days'), + Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY => $this->l('Check-in day | Check-out days'), + Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY => $this->l('Check-in day | During-stay days'), + Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY => $this->l('Check-out day | During-stay days'), + Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY => $this->l('Check-in day | During-stay days | Check-out day'), ); $this->_join .= ' @@ -331,12 +331,12 @@ class AdminNormalProductsControllerCore extends AdminController // Code For Standard product working $sellingPreferenceTypes = array( Product::SELLING_PREFERENCE_WITH_ROOM_TYPE => $this->l('With room type'), - Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE => $this->l('With hotel|room type'), - Product::SELLING_PREFERENCE_WITH_STANDALONE => $this->l('Standalone'), + Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE => $this->l('With hotel | With room type'), + Product::SELLING_PREFERENCE_WITH_STANDALONE => $this->l('With Standalone'), Product::SELLING_PREFERENCE_WITH_HOTEL => $this->l('With hotel'), - Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE => $this->l('With hotel|standalone'), - Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE => $this->l('With room type|standalone'), - Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE => $this->l('With hotel|room type|standalone'), + Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE => $this->l('With hotel | With standalone'), + Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE => $this->l('With room type | With standalone'), + Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE => $this->l('With hotel | With room type | With standalone'), ); $this->fields_list['selling_preference_type'] = array( 'type' => 'select', @@ -435,27 +435,38 @@ class AdminNormalProductsControllerCore extends AdminController { $list = $this->fields_list['selling_preference_type']['list']; - if (!isset($list[$selling_preference_type])) { + if (empty($list[$selling_preference_type])) { return '--'; } - $this->context->smarty->assign('selected_options', array_map('trim', explode('|', $list[$selling_preference_type]))); + $options = array_map('trim', explode('|', $list[$selling_preference_type])); - return $this->context->smarty->fetch('controllers/normal_products/selected_option.tpl'); + $this->context->smarty->assign(array( + 'tooltip_items' => $options, + )); + + $tooltip = $this->context->smarty->fetch('helpers/tooltip.tpl'); + + return count($options) . ' ' . $this->l('Selected') . ' ' . $tooltip; } - public function getPriceCalculationMethod($txt, $row) + public function getPriceCalculationMethod($price_calculation_method, $row) { $list = $this->fields_list['price_calculation_method']['list']; - $method = (int)$row['price_calculation_method']; - if (!isset($list[$method])) { + if (empty($list[$price_calculation_method])) { return '--'; } - $this->context->smarty->assign('selected_options', array_map('trim', explode('|', $list[$method]))); + $options = array_map('trim', explode('|', $list[$price_calculation_method])); - return $this->context->smarty->fetch('controllers/normal_products/selected_option.tpl'); + $this->context->smarty->assign(array( + 'tooltip_items' => $options, + )); + + $tooltip = $this->context->smarty->fetch('helpers/tooltip.tpl'); + + return count($options) . ' ' . $this->l('Selected') . ' ' . $tooltip; } public function getHotelName($hotelName, $row) @@ -1543,7 +1554,6 @@ class AdminNormalProductsControllerCore extends AdminController _PS_CSS_DIR_.'ps-hotel-reservation.css', )); }else { - $this->addCSS(__PS_BASE_URI__.$this->admin_webpath.'/themes/default/css/admin-tooltip.css'); $this->addJqueryUI('ui.tooltip', 'base', true); } } @@ -2374,7 +2384,10 @@ class AdminNormalProductsControllerCore extends AdminController $this->errors[] = $this->l('Please select at least one buying option.'); } - if (!Tools::getValue('price_calculation_method')) { + $priceCalculationMethod = Tools::getValue('price_calculation_method'); + $id = Tools::getValue('id_'.$this->table); + + if (isset($priceCalculationMethod, $id) && empty($priceCalculationMethod) && !empty($id)) { $this->errors[] = $this->l('Please select at least one price calculation method.'); } diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index b6c9418a6..c42480eca 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -1379,7 +1379,6 @@ class AdminOrdersControllerCore extends AdminController $this->addJqueryUI('ui.datepicker'); $this->addJS(_PS_JS_DIR_.'vendor/d3.v3.min.js'); - $this->addCSS(__PS_BASE_URI__.$this->admin_webpath.'/themes/default/css/admin-tooltip.css'); $this->addJqueryUI(array('ui.tooltip'), 'base', true); if ($this->display == 'view') { diff --git a/js/admin/orders.js b/js/admin/orders.js index 567c9c164..981e75051 100644 --- a/js/admin/orders.js +++ b/js/admin/orders.js @@ -1466,15 +1466,7 @@ $(document).ready(function() { }, complete: function() { $(".loading_overlay").hide(); - initAdminTooltip({ - selector: '.price-calculation-info', - items: 'span', - tooltipClass: 'admin-info-tooltip', - skipIfInitialized: true, - getContent: function () { - return $(this).siblings('.price-calculation-info-container').html(); - } - }); + initTooltip(); } }); }); @@ -2546,15 +2538,7 @@ const EditRoomBookingModal = { // initialize datepickers EditRoomBookingModal.initDatePickers(); - initAdminTooltip({ - selector: '.price-calculation-info', - items: 'span', - tooltipClass: 'admin-info-tooltip', - skipIfInitialized: true, - getContent: function () { - return $(this).siblings('.price-calculation-info-container').html(); - } - }); + initTooltip(); $('#edit_product .extra-services-container #id_htl_booking').val(jsonProductLineData.id); $('#edit-room-booking-modal').modal('show'); } else { diff --git a/modules/hotelreservationsystem/views/js/admin/wk_refund_request.js b/modules/hotelreservationsystem/views/js/admin/wk_refund_request.js index 7bf27b61f..a74ad4bf1 100644 --- a/modules/hotelreservationsystem/views/js/admin/wk_refund_request.js +++ b/modules/hotelreservationsystem/views/js/admin/wk_refund_request.js @@ -41,45 +41,6 @@ $(document).ready(function() { $('#voucher_expiry').parent().removeClass('has-error'); }); - // initialize tootip for room price - if ($('#rooms_refund_info .price_info').length) { - $('#rooms_refund_info .price_info').each(function (i, element) { - $(this).find('img').tooltip({ - content: $(this).closest('td').find('.price_info_container').html(), - items: "span", - trigger : 'hover', - tooltipClass: "price_info-tooltip", - open: function(event, ui) - { - if (typeof(event.originalEvent) === 'undefined') - { - return false; - } - - var $id = $(ui.tooltip).attr('id'); - - if ($('div.ui-tooltip').not('#' + $id).length) { - return false; - } - }, - close: function(event, ui) - { - ui.tooltip.hover(function() - { - $(this).stop(true).fadeTo(400, 1); - }, - function() - { - $(this).fadeOut('400', function() - { - $(this).remove(); - }); - }); - } - }); - }); - } - $(document).on('change', '#refundTransactionAmount', function() { if ($(this).is(':checked')) { $(".refund_transaction_fields").show(200); diff --git a/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl b/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl index 3a181b149..84faaa7a9 100644 --- a/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl @@ -171,35 +171,23 @@
{dateFormat date=$booking['date_from'] full=$is_full_date} {l s='To' mod='hotelreservationsystem'} {dateFormat date=$booking['date_to'] full=$is_full_date} {displayPrice price=($booking['total_price_tax_incl'] + $booking['extra_service_total_price_tax_incl']) currency=$orderCurrency['id']} - -   - - {displayPrice price=($booking['room_paid_amount'] + $booking['extra_service_total_paid_amount']) currency=$orderCurrency['id']} - -   - - diff --git a/themes/hotel-reservation-theme/product.tpl b/themes/hotel-reservation-theme/product.tpl index f9836c246..67f4a03fe 100644 --- a/themes/hotel-reservation-theme/product.tpl +++ b/themes/hotel-reservation-theme/product.tpl @@ -455,7 +455,7 @@ {/if}
-

{$demand['name']|escape:'html':'UTF-8'} {if $product->show_price && !isset($restricted_country_mode) && !$PS_CATALOG_MODE}{convertPrice price = $demand['price']}{if $demand['price_calc_method'] == $WK_PRICE_CALC_METHOD_EACH_DAY}{l s='/night'}{/if}{/if}

+

{$demand['name']|escape:'html':'UTF-8'} {if $product->show_price && !isset($restricted_country_mode) && !$PS_CATALOG_MODE}{convertPrice price = $demand['price']}{if $demand['price_calc_method'] == $WK_PRICE_CALC_METHOD_EACH_DAY}{l s='/Night'}{/if}{/if}

{if isset($demand['adv_option']) && $demand['adv_option']}
diff --git a/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl b/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl index 44f2672ca..3d87a0286 100644 --- a/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl +++ b/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl @@ -68,24 +68,9 @@
    - {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} -
  • {l s='Check-in day'}
  • - {/if} - {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} -
  • {l s='During-stay days'}
  • - {/if} - {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} -
  • {l s='Check-out day'}
  • - {/if} + {foreach from=Product::getPriceCalculationMethodDaysLabel($priceCalcMethod) item='pcmDayLabel'} +
  • {$pcmDayLabel}
  • + {/foreach}
{/capture} @@ -165,22 +150,21 @@
-
diff --git a/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl b/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl index f98d22808..aa650fca3 100644 --- a/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl +++ b/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl @@ -60,24 +60,9 @@
    - {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} -
  • {l s='Check-in day'}
  • - {/if} - {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} -
  • {l s='During-stay days'}
  • - {/if} - {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} -
  • {l s='Check-out day'}
  • - {/if} + {foreach from=Product::getPriceCalculationMethodDaysLabel($priceCalcMethod) item='pcmDayLabel'} +
  • {$pcmDayLabel}
  • + {/foreach}
{/capture} @@ -170,24 +155,9 @@
    - {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} -
  • {l s='Check-in day'}
  • - {/if} - {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} -
  • {l s='During-stay days'}
  • - {/if} - {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} -
  • {l s='Check-out day'}
  • - {/if} + {foreach from=Product::getPriceCalculationMethodDaysLabel($priceCalcMethod) item='pcmDayLabel'} +
  • {$pcmDayLabel}
  • + {/foreach}
{/capture} @@ -256,22 +226,21 @@
-
@@ -356,24 +325,9 @@
    - {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} -
  • {l s='Check-in day'}
  • - {/if} - {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} -
  • {l s='During-stay days'}
  • - {/if} - {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} -
  • {l s='Check-out day'}
  • - {/if} + {foreach from=Product::getPriceCalculationMethodDaysLabel($priceCalcMethod) item='pcmDayLabel'} +
  • {$pcmDayLabel}
  • + {/foreach}
{/capture} diff --git a/classes/Product.php b/classes/Product.php index b72de541a..ddc01e52d 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -6931,7 +6931,28 @@ class ProductCore extends ObjectModel return $numNights; } } - + + public static function getPriceCalculationMethodDaysLabel($priceCalculationMethod) + { + $priceCalculationMethod = (int) $priceCalculationMethod; + $labels = array(); + static $module = null; + if (is_null($module)) { + $module = Module::getInstanceByName('hotelreservationsystem'); + } + if ($priceCalculationMethod & self::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY) { + $labels[] = $module->l('Check-in day'); + } + if ($priceCalculationMethod & self::PRICE_CALCULATION_METHOD_ON_DURING_STAY) { + $labels[] = $module->l('During-stay days'); + } + if ($priceCalculationMethod & self::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY) { + $labels[] = $module->l('Check-out day'); + } + + return $labels; + } + public static function isSellableWithRoomType($idProduct) { return in_array((int) self::getSellingPreferenceType($idProduct), [ diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index 456976c9f..3e689f2d6 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -1399,6 +1399,9 @@ class AdminCartsControllerCore extends AdminController $name = trim(Tools::getValue('new_service_name')); $price = Tools::getValue('new_service_price'); $priceCalcMethod = Tools::getValue('new_service_price_calc_method'); + if (is_array($priceCalcMethod)) { + $priceCalcMethod = array_sum(array_map('intval', $priceCalcMethod)); + } $priceAdditionType = Tools::getValue('new_service_price_addition_type'); $productQty = Tools::getValue('new_service_qty'); $idTaxRuleGroup = Tools::getValue('new_service_price_tax_rule_group'); diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index c3486efe4..be9f8adb7 100644 --- a/controllers/admin/AdminNormalProductsController.php +++ b/controllers/admin/AdminNormalProductsController.php @@ -433,32 +433,23 @@ class AdminNormalProductsControllerCore extends AdminController public function getBuyingOption($selling_preference_type, $row) { - $list = $this->fields_list['selling_preference_type']['list']; - - if (empty($list[$selling_preference_type])) { - return '--'; - } - - $options = array_map('trim', explode('|', $list[$selling_preference_type])); - - $this->context->smarty->assign(array( - 'tooltip_items' => $options, - )); - - $tooltip = $this->context->smarty->fetch('helpers/tooltip.tpl'); - - return count($options) . ' ' . $this->l('Selected') . ' ' . $tooltip; + return $this->renderMultiSelectTooltip('selling_preference_type', $selling_preference_type); } public function getPriceCalculationMethod($price_calculation_method, $row) { - $list = $this->fields_list['price_calculation_method']['list']; + return $this->renderMultiSelectTooltip('price_calculation_method', $price_calculation_method); + } - if (empty($list[$price_calculation_method])) { + private function renderMultiSelectTooltip($fieldKey, $value) + { + $list = $this->fields_list[$fieldKey]['list']; + + if (empty($list[$value])) { return '--'; } - $options = array_map('trim', explode('|', $list[$price_calculation_method])); + $options = array_map('trim', explode('|', $list[$value])); $this->context->smarty->assign(array( 'tooltip_items' => $options, @@ -531,6 +522,9 @@ class AdminNormalProductsControllerCore extends AdminController */ protected function copyFromPost(&$object, $table) { + if (is_array(Tools::getValue('price_calculation_method'))) { + $_POST['price_calculation_method'] = array_sum(array_map('intval', Tools::getValue('price_calculation_method'))); + } parent::copyFromPost($object, $table); if (get_class($object) != 'Product') { return; @@ -2229,6 +2223,10 @@ class AdminNormalProductsControllerCore extends AdminController */ public function checkProduct() { + if (is_array(Tools::getValue('price_calculation_method'))) { + $_POST['price_calculation_method'] = array_sum(array_map('intval', Tools::getValue('price_calculation_method'))); + } + $className = 'Product'; // @todo : the call_user_func seems to contains only statics values (className = 'Product') $rules = call_user_func(array($this->className, 'getValidationRules'), $this->className); @@ -2384,10 +2382,7 @@ class AdminNormalProductsControllerCore extends AdminController $this->errors[] = $this->l('Please select at least one buying option.'); } - $priceCalculationMethod = Tools::getValue('price_calculation_method'); - $id = Tools::getValue('id_'.$this->table); - - if (isset($priceCalculationMethod, $id) && empty($priceCalculationMethod) && !empty($id)) { + if (!Tools::getValue('price_calculation_method')) { $this->errors[] = $this->l('Please select at least one price calculation method.'); } diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index d06f0288f..2394d5971 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -8185,6 +8185,9 @@ class AdminOrdersControllerCore extends AdminController $name = trim(Tools::getValue('new_service_name')); $price = Tools::getValue('new_service_price'); $priceCalcMethod = Tools::getValue('new_service_price_calc_method'); + if (is_array($priceCalcMethod)) { + $priceCalcMethod = array_sum(array_map('intval', $priceCalcMethod)); + } $priceAdditionType = Tools::getValue('new_service_price_addition_type'); $productQty = Tools::getValue('new_service_qty'); $idTaxRuleGroup = Tools::getValue('new_service_price_tax_rule_group'); diff --git a/js/admin.js b/js/admin.js index 37cc6fc89..b42e2e297 100644 --- a/js/admin.js +++ b/js/admin.js @@ -1764,15 +1764,3 @@ function closeRecommendation() } }); } - -function applyPriceCalcMethodValue() -{ - var ci = $('#pcm_checkin').is(':checked') ? 1 : 0; - var co = $('#pcm_checkout').is(':checked') ? 2 : 0; - var ds = $('#pcm_duringstay').is(':checked') ? 4 : 0; - $('#price_calculation_method').val(ci + co + ds); -} -$(document).on('change','#pcm_checkin, #pcm_checkout, #pcm_duringstay', function() { - applyPriceCalcMethodValue(); -}); -applyPriceCalcMethodValue(); \ No newline at end of file diff --git a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl index a93973d7c..29c049efe 100644 --- a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl +++ b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl @@ -140,24 +140,9 @@

{l s='Applied on:'}

    - {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} -
  • {l s='Check-in day'}
  • - {/if} - {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} -
  • {l s='During-stay days'}
  • - {/if} - {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} -
  • {l s='Check-out day'}
  • - {/if} + {foreach from=Product::getPriceCalculationMethodDaysLabel($priceCalcMethod) item='pcmDayLabel'} +
  • {$pcmDayLabel}
  • + {/foreach}
{/capture} diff --git a/themes/hotel-reservation-theme/_partials/order-extra-services.tpl b/themes/hotel-reservation-theme/_partials/order-extra-services.tpl index f764048e7..7d9717739 100644 --- a/themes/hotel-reservation-theme/_partials/order-extra-services.tpl +++ b/themes/hotel-reservation-theme/_partials/order-extra-services.tpl @@ -63,24 +63,9 @@

{l s='Applied on:'}

    - {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} -
  • {l s='Check-in day'}
  • - {/if} - {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} -
  • {l s='During-stay days'}
  • - {/if} - {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} -
  • {l s='Check-out day'}
  • - {/if} + {foreach from=Product::getPriceCalculationMethodDaysLabel($priceCalcMethod) item='pcmDayLabel'} +
  • {$pcmDayLabel}
  • + {/foreach}
{/capture} diff --git a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl index ea97398e2..1a4db4d15 100644 --- a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl +++ b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl @@ -43,24 +43,9 @@

{l s='Applied on:'}

    - {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} -
  • {l s='Check-in day'}
  • - {/if} - {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} -
  • {l s='During-stay days'}
  • - {/if} - {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY - || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} -
  • {l s='Check-out day'}
  • - {/if} + {foreach from=Product::getPriceCalculationMethodDaysLabel($priceCalcMethod) item='pcmDayLabel'} +
  • {$pcmDayLabel}
  • + {/foreach}
{/capture} From 12d2001fdb9bd9937c34559a1cfc44c29408dd9f Mon Sep 17 00:00:00 2001 From: amit sharma Date: Wed, 19 Aug 2026 15:31:01 +0530 Subject: [PATCH 24/34] Fixed:fix tooltip icon position --- themes/hotel-reservation-theme/css/global.css | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/themes/hotel-reservation-theme/css/global.css b/themes/hotel-reservation-theme/css/global.css index 0eeba6ea7..44dafbeee 100644 --- a/themes/hotel-reservation-theme/css/global.css +++ b/themes/hotel-reservation-theme/css/global.css @@ -9400,8 +9400,7 @@ div a.our_properties_link{ .htl-tooltip { cursor: pointer; display: inline-block; - vertical-align: middle; - margin-left: 4px; + vertical-align: text-bottom; } .ui-tooltip.htl-tooltip-popup { From ad010a6809a24a317a36ed8fcd971bef8aec2f93 Mon Sep 17 00:00:00 2001 From: amit sharma Date: Wed, 19 Aug 2026 15:47:39 +0530 Subject: [PATCH 25/34] Fixed: variable validation issue Co-authored-by: Name --- controllers/admin/AdminNormalProductsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index be9f8adb7..741e71fdd 100644 --- a/controllers/admin/AdminNormalProductsController.php +++ b/controllers/admin/AdminNormalProductsController.php @@ -2382,7 +2382,7 @@ class AdminNormalProductsControllerCore extends AdminController $this->errors[] = $this->l('Please select at least one buying option.'); } - if (!Tools::getValue('price_calculation_method')) { + if (Tools::getValue('id_product') && !Tools::getValue('price_calculation_method')) { $this->errors[] = $this->l('Please select at least one price calculation method.'); } From 0fd5d98eea9a9139d4384aed5ba302d29c2240fb Mon Sep 17 00:00:00 2001 From: amit sharma Date: Wed, 19 Aug 2026 16:27:03 +0530 Subject: [PATCH 26/34] Fixed: fix feedback changes related to the selling preference types --- .../template/controllers/normal_products/informations.tpl | 7 +++---- controllers/admin/AdminNormalProductsController.php | 4 ++++ js/admin/normal_products.js | 6 ------ 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/admin/themes/default/template/controllers/normal_products/informations.tpl b/admin/themes/default/template/controllers/normal_products/informations.tpl index 66435dda0..a49e34a81 100644 --- a/admin/themes/default/template/controllers/normal_products/informations.tpl +++ b/admin/themes/default/template/controllers/normal_products/informations.tpl @@ -237,24 +237,23 @@
-
diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index 741e71fdd..b6ec03e28 100644 --- a/controllers/admin/AdminNormalProductsController.php +++ b/controllers/admin/AdminNormalProductsController.php @@ -2227,6 +2227,10 @@ class AdminNormalProductsControllerCore extends AdminController $_POST['price_calculation_method'] = array_sum(array_map('intval', Tools::getValue('price_calculation_method'))); } + if (is_array(Tools::getValue('selling_preference_type'))) { + $_POST['selling_preference_type'] = array_sum(array_map('intval', Tools::getValue('selling_preference_type'))); + } + $className = 'Product'; // @todo : the call_user_func seems to contains only statics values (className = 'Product') $rules = call_user_func(array($this->className, 'getValidationRules'), $this->className); diff --git a/js/admin/normal_products.js b/js/admin/normal_products.js index b5f53dee7..131b29c42 100644 --- a/js/admin/normal_products.js +++ b/js/admin/normal_products.js @@ -573,12 +573,6 @@ product_tabs['Informations'] = new function(){ var withRoomType = $('#sp_with_room_type').is(':checked'); var withHotel = $('#sp_with_hotel').is(':checked'); var standalone = $('#sp_standalone').is(':checked'); - const sellingPreference = - (withRoomType ? SELLING_PREFERENCE_WITH_ROOM_TYPE : 0) | - (withHotel ? SELLING_PREFERENCE_WITH_HOTEL : 0) | - (standalone ? SELLING_PREFERENCE_WITH_STANDALONE : 0); - - $('#selling_preference_type').val(sellingPreference); var $autoAddOff = $('#auto_add_to_cart_off'); var $autoAddCheckedInput; From 4def31481b3e320ab1a2454bedea974a73a92f07 Mon Sep 17 00:00:00 2001 From: amit sharma Date: Thu, 20 Aug 2026 10:37:49 +0530 Subject: [PATCH 27/34] Fixed: Standard Product Comments --- .../normal_products/informations.tpl | 4 +- .../admin/AdminNormalProductsController.php | 60 ++++++++++--------- js/admin/normal_products.js | 3 +- 3 files changed, 35 insertions(+), 32 deletions(-) diff --git a/admin/themes/default/template/controllers/normal_products/informations.tpl b/admin/themes/default/template/controllers/normal_products/informations.tpl index a49e34a81..f049745e3 100644 --- a/admin/themes/default/template/controllers/normal_products/informations.tpl +++ b/admin/themes/default/template/controllers/normal_products/informations.tpl @@ -230,7 +230,7 @@
{* Code For Standard product working *} -
+ {*
-
+
*}
id)}style="display:none;"{/if}>
{include file="controllers/products/multishop/checkbox.tpl" field="category_box" type="category_box"}
{if ($product.show_price && !isset($restricted_country_mode)) || isset($groups)} - {if !$priceDisplay}{convertPrice price=$product.price_tax_incl}{else}{convertPrice price=$product.price_tax_exc}{/if}{if $product.price_calculation_method == Product::PRICE_CALCULATION_METHOD_PER_DAY}{l s='/Night'}{/if} + {if !$priceDisplay}{convertPrice price=$product.price_tax_incl}{else}{convertPrice price=$product.price_tax_exc}{/if} + {if Product::getServicePriceBillableDays( + $product.price_calculation_method, + $product.date_from|default:$date_from|default:'', + $product.date_to|default:$date_to|default:'' + ) > 1} + {l s='/Night'} + {/if} + {/if}
From 1e10910b43e823b5e1231f0e421034ec5c4462bb Mon Sep 17 00:00:00 2001 From: amit sharma Date: Mon, 7 Sep 2026 17:36:13 +0530 Subject: [PATCH 30/34] Fixed : fix cart rule issue on standalone products --- classes/Cart.php | 21 ++++++++++++++++++--- classes/CartRule.php | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/classes/Cart.php b/classes/Cart.php index 553dc1515..8087b1b12 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -1762,11 +1762,26 @@ class CartCore extends ObjectModel if ($param_product && isset($product['selling_preference_type'])) { $canSellWithRoomType = $canSellWithRoomType - && ($product['selling_preference_type'] == Product::SELLING_PREFERENCE_WITH_ROOM_TYPE); + && in_array((int) $product['selling_preference_type'], array( + Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, + Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE, + Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE, + Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, + )); $canSellWithHotel = $canSellWithHotel - && ($product['selling_preference_type'] == Product::SELLING_PREFERENCE_WITH_HOTEL); + && in_array((int) $product['selling_preference_type'], array( + Product::SELLING_PREFERENCE_WITH_HOTEL, + Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE, + Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE, + Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, + )); $canSellAsStandalone = $canSellAsStandalone - && ($product['selling_preference_type'] == Product::SELLING_PREFERENCE_WITH_STANDALONE); + && in_array((int) $product['selling_preference_type'], array( + Product::SELLING_PREFERENCE_WITH_STANDALONE, + Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE, + Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE, + Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, + )); } if ($canSellAsStandalone && !$isRoomServiceTotalType) { diff --git a/classes/CartRule.php b/classes/CartRule.php index 69ebd063b..05f9076d4 100644 --- a/classes/CartRule.php +++ b/classes/CartRule.php @@ -1007,7 +1007,7 @@ class CartRuleCore extends ObjectModel continue; } } - $cache_id .= '_'.(int)$product['id_product'].'_'.(int)$product['id_product_attribute'].(isset($product['in_stock']) ? '_'.(int)$product['in_stock'] : ''); + $cache_id .= '_'.(int)$product['id_product'].'_'.(int)$product['id_product_attribute'].'_'.(int)$product['cart_quantity'].(isset($product['in_stock']) ? '_'.(int)$product['in_stock'] : ''); } $package_products = $package['products']; From 86de0b356ddbf7ccafaf3d48d296e1413b8cbcd0 Mon Sep 17 00:00:00 2001 From: amit sharma Date: Wed, 9 Sep 2026 13:17:34 +0530 Subject: [PATCH 31/34] Fixed: fix room type wrong price display issue Co-authored-by: Name --- modules/blockcart/blockcart.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/blockcart/blockcart.php b/modules/blockcart/blockcart.php index 8ad965c04..eb1c57c24 100644 --- a/modules/blockcart/blockcart.php +++ b/modules/blockcart/blockcart.php @@ -429,7 +429,7 @@ class Blockcart extends Module 'wrapping_cost' => Tools::displayPrice($wrappingCost, $currency), 'product_total' => Tools::displayPrice($params['cart']->getOrderTotal($useTax, Cart::ONLY_PRODUCTS), $currency), 'room_total' => ($totalRoomsPrice + $totalAdditionalServicesWithAutoAddPrice), - 'room_total_format' => Tools::displayPrice($totalRoomsPrice + $totalAdditionalServicesWithAutoAddPrice - $totalConvenienceFee), + 'room_total_format' => Tools::displayPrice($totalRoomsPrice + $totalAdditionalServicesWithAutoAddPrice), 'totalToPay' => $totalToPay, 'total_convenience_fee' => $totalConvenienceFee, 'total_convenience_fee_format' => Tools::displayPrice(($totalConvenienceFee), $currency), From 93c64493ead7b64140f1e5e1fa9cdfd34bdfab04 Mon Sep 17 00:00:00 2001 From: amit sharma Date: Wed, 16 Sep 2026 15:26:19 +0530 Subject: [PATCH 32/34] Fixed: added new changes Co-authored-by: Name --- .../_price_calculation_method_options.tpl | 30 -------------- .../controllers/normal_products/prices.tpl | 28 ++++++++++++- classes/Product.php | 12 +++++- .../admin/AdminNormalProductsController.php | 40 ++++++++++--------- 4 files changed, 59 insertions(+), 51 deletions(-) delete mode 100644 admin/themes/default/template/controllers/normal_products/_price_calculation_method_options.tpl diff --git a/admin/themes/default/template/controllers/normal_products/_price_calculation_method_options.tpl b/admin/themes/default/template/controllers/normal_products/_price_calculation_method_options.tpl deleted file mode 100644 index 5f6a22d5e..000000000 --- a/admin/themes/default/template/controllers/normal_products/_price_calculation_method_options.tpl +++ /dev/null @@ -1,30 +0,0 @@ -{* -* NOTICE OF LICENSE -* -* This source file is subject to the Open Software License version 3.0 -* that is bundled with this package in the file LICENSE.md -* It is also available through the world-wide-web at this URL: -* https://opensource.org/license/osl-3-0-php -* If you did not receive a copy of the license and are unable to -* obtain it through the world-wide-web, please send an email -* to support@qloapps.com so we can send you a copy immediately. -* -* DISCLAIMER -* -* Do not edit or add to this file if you wish to upgrade this module to a newer -* versions in the future. If you wish to customize this module for your needs -* please refer to https://store.webkul.com/customisation-guidelines for more information. -* -* @author Webkul IN -* @copyright Since 2010 Webkul -* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0 -*} - -{capture name='tooltip_list_content'} -
    - {foreach $tooltip_items as $tooltip_item} -
  • {$tooltip_item|escape:'html':'UTF-8'}
  • - {/foreach} -
-{/capture} -{include file='helpers/tooltip.tpl' tooltip_content=$smarty.capture.tooltip_list_content allow_html=true} diff --git a/admin/themes/default/template/controllers/normal_products/prices.tpl b/admin/themes/default/template/controllers/normal_products/prices.tpl index 375f291a4..7ec1647fb 100644 --- a/admin/themes/default/template/controllers/normal_products/prices.tpl +++ b/admin/themes/default/template/controllers/normal_products/prices.tpl @@ -212,10 +212,23 @@ $(document).ready(function () {
*}
+
+ +
+
+
+
+ {* As no use in QloApps currently so commented *} {*
{include file="controllers/products/multishop/checkbox.tpl" field="unit_price" type="unit_price"}
diff --git a/classes/Product.php b/classes/Product.php index f683b0a67..5a59e6045 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -567,11 +567,12 @@ class ProductCore extends ObjectModel const PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY = 1; const PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY = 2; - const PRICE_CALCULATION_METHOD_ON_DURING_STAY = 4; const PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY = 3; + const PRICE_CALCULATION_METHOD_ON_DURING_STAY = 4; const PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY = 5; const PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY = 6; const PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY = 7; + const PRICE_CALCULATION_METHOD_ONCE_FOR_BOOKING = 8; const STANDARD_PRODUCT_ADDRESS_PREFERENCE_CUSTOMER = 1; const STANDARD_PRODUCT_ADDRESS_PREFERENCE_HOTEL = 2; @@ -6913,6 +6914,9 @@ class ProductCore extends ObjectModel $stayDay = $numNights - 1; switch ((int) $priceCalculationMethod) { + case self::PRICE_CALCULATION_METHOD_ONCE_FOR_BOOKING: + return 1; + case self::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY: return $checkinDay; @@ -6947,6 +6951,12 @@ class ProductCore extends ObjectModel if (is_null($module)) { $module = Module::getInstanceByName('hotelreservationsystem'); } + if ($priceCalculationMethod == self::PRICE_CALCULATION_METHOD_ONCE_FOR_BOOKING) { + $labels[] = $module->l('Once per booking'); + + return $labels; + } + if ($priceCalculationMethod & self::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY) { $labels[] = $module->l('Check-in day'); } diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index 69010afe9..fc1494555 100644 --- a/controllers/admin/AdminNormalProductsController.php +++ b/controllers/admin/AdminNormalProductsController.php @@ -207,6 +207,7 @@ class AdminNormalProductsControllerCore extends AdminController Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY => $this->l('Check-in day | During-stay days'), Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY => $this->l('Check-out day | During-stay days'), Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY => $this->l('Check-in day | During-stay days | Check-out day'), + Product::PRICE_CALCULATION_METHOD_ONCE_FOR_BOOKING => $this->l('Once per booking'), ); $this->_join .= ' @@ -433,31 +434,28 @@ class AdminNormalProductsControllerCore extends AdminController public function getBuyingOption($selling_preference_type, $row) { - return $this->renderMultiSelectTooltip('selling_preference_type', $selling_preference_type); + $list = $this->fields_list['selling_preference_type']['list']; + + if (empty($list[$selling_preference_type])) { + return '--'; + } + + $options = array_map('trim', explode('|', $list[$selling_preference_type])); + + return implode(', ', $options); } public function getPriceCalculationMethod($price_calculation_method, $row) { - return $this->renderMultiSelectTooltip('price_calculation_method', $price_calculation_method); - } + $list = $this->fields_list['price_calculation_method']['list']; - private function renderMultiSelectTooltip($fieldKey, $value) - { - $list = $this->fields_list[$fieldKey]['list']; - - if (empty($list[$value])) { + if (empty($list[$price_calculation_method])) { return '--'; } - $options = array_map('trim', explode('|', $list[$value])); + $options = array_map('trim', explode('|', $list[$price_calculation_method])); - $this->context->smarty->assign(array( - 'tooltip_items' => $options, - )); - - $tooltip = $this->context->smarty->fetch('controllers/normal_products/_price_calculation_method_options.tpl'); - - return count($options) . ' ' . $this->l('Selected') . ' ' . $tooltip; + return implode(', ', $options); } public function getHotelName($hotelName, $row) @@ -522,7 +520,9 @@ class AdminNormalProductsControllerCore extends AdminController */ protected function copyFromPost(&$object, $table) { - if (is_array(Tools::getValue('price_calculation_method'))) { + if (Tools::getValue('price_calculation_type') == Product::PRICE_CALCULATION_METHOD_ONCE_FOR_BOOKING) { + $_POST['price_calculation_method'] = Product::PRICE_CALCULATION_METHOD_ONCE_FOR_BOOKING; + } elseif (is_array(Tools::getValue('price_calculation_method'))) { $_POST['price_calculation_method'] = array_sum(array_map('intval', Tools::getValue('price_calculation_method'))); } parent::copyFromPost($object, $table); @@ -2254,7 +2254,9 @@ class AdminNormalProductsControllerCore extends AdminController */ public function checkProduct() { - if (is_array(Tools::getValue('price_calculation_method'))) { + if (Tools::getValue('price_calculation_type') == Product::PRICE_CALCULATION_METHOD_ONCE_FOR_BOOKING) { + $_POST['price_calculation_method'] = Product::PRICE_CALCULATION_METHOD_ONCE_FOR_BOOKING; + } elseif (is_array(Tools::getValue('price_calculation_method'))) { $_POST['price_calculation_method'] = array_sum(array_map('intval', Tools::getValue('price_calculation_method'))); } @@ -2420,7 +2422,7 @@ class AdminNormalProductsControllerCore extends AdminController // } if (Tools::getValue('id_product') && !Tools::getValue('price_calculation_method')) { - $this->errors[] = $this->l('Please select at least one price calculation method.'); + $this->errors[] = $this->l('Please select at least one day to apply the price calculation method on.'); } // Tags From 2c993bb212f86e43205709ebb8b668437dea9874 Mon Sep 17 00:00:00 2001 From: amit sharma Date: Wed, 16 Sep 2026 17:32:29 +0530 Subject: [PATCH 33/34] Fixed: Fix service product price calculation in Order and Cart controllers --- .../template/controllers/orders/form.tpl | 8 ++++ .../controllers/orders/helpers/view/view.tpl | 1 + .../_add_order_extra_services_tab_content.tpl | 47 ++++++++++++------- ..._services_service_products_tab_content.tpl | 47 ++++++++++++------- controllers/admin/AdminCartsController.php | 9 ++-- controllers/admin/AdminOrdersController.php | 9 ++-- js/admin/orders.js | 8 ++++ 7 files changed, 87 insertions(+), 42 deletions(-) diff --git a/admin/themes/default/template/controllers/orders/form.tpl b/admin/themes/default/template/controllers/orders/form.tpl index f0d4fe766..dcbcf7b02 100644 --- a/admin/themes/default/template/controllers/orders/form.tpl +++ b/admin/themes/default/template/controllers/orders/form.tpl @@ -35,6 +35,7 @@ var can_edit_booking_carts = {if isset($can_edit_booking_carts) && $can_edit_booking_carts}true{else}false{/if}; var can_add_addresses = {if isset($can_add_addresses) && $can_add_addresses}true{else}false{/if}; var admin_order_tab_link = "{$link->getAdminLink('AdminOrders')|addslashes}"; + var new_service_pcm_once_for_booking = {Product::PRICE_CALCULATION_METHOD_ONCE_FOR_BOOKING|intval}; var changed_shipping_price = false; var shipping_price_selected_carrier = ''; var current_index = '{$current|escape:'html':'UTF-8'}&token={$token|escape:'html':'UTF-8'}'; @@ -53,6 +54,13 @@ var priceDisplayPrecision = {$smarty.const._PS_PRICE_DISPLAY_PRECISION_|intval}; $(document).ready(function() { + $(document).on('change', '#add_new_room_services_form select[name="price_calculation_type"]', function() { + if ($(this).val() == new_service_pcm_once_for_booking) { + $('#new_service_pcm_days_container').hide(); + } else { + $('#new_service_pcm_days_container').show(); + } + }); $('.total_taxes_price_info img').tooltip({ content: function () { diff --git a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl index e409deff6..1dbb62246 100644 --- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -44,6 +44,7 @@