From 5317491b6e295ab3032166e9c455a7696946d046 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Fri, 18 Aug 2023 12:36:53 +0530 Subject: [PATCH] Fix room price issue for customer after adding room with custom price at BO --- .../template/controllers/orders/form.tpl | 8 +- controllers/admin/AdminOrdersController.php | 74 ++++++++----------- 2 files changed, 35 insertions(+), 47 deletions(-) diff --git a/admin/themes/default/template/controllers/orders/form.tpl b/admin/themes/default/template/controllers/orders/form.tpl index 99b5ab612..08514a115 100644 --- a/admin/themes/default/template/controllers/orders/form.tpl +++ b/admin/themes/default/template/controllers/orders/form.tpl @@ -675,11 +675,11 @@ } function updateCartSummaryData(summaryData) { - $('#total_rooms').html(formatCurrency(parseFloat(jsonSummary.summary.total_rooms + jsonSummary.summary.total_extra_demands + jsonSummary.summary.total_additional_services + jsonSummary.summary.total_additional_services_auto_add), currency_format, currency_sign, currency_blank)); + $('#total_rooms').html(formatCurrency(parseFloat(summaryData.summary.total_rooms + summaryData.summary.total_extra_demands + summaryData.summary.total_additional_services + summaryData.summary.total_additional_services_auto_add), currency_format, currency_sign, currency_blank)); $('#total_vouchers').html(formatCurrency(parseFloat(summaryData.summary.total_discounts_tax_exc), currency_format, currency_sign, currency_blank)); - $('#total_convenience_fees').html(formatCurrency(parseFloat(jsonSummary.summary.convenience_fee), currency_format, currency_sign, currency_blank)); - $('#total_without_taxes').html(formatCurrency(parseFloat(jsonSummary.summary.total_price_without_tax - jsonSummary.summary.convenience_fee), currency_format, currency_sign, currency_blank)); - // $('#total_service_products').html(formatCurrency(parseFloat(jsonSummary.summary.total_service_products), currency_format, currency_sign, currency_blank)); + $('#total_convenience_fees').html(formatCurrency(parseFloat(summaryData.summary.convenience_fee), currency_format, currency_sign, currency_blank)); + $('#total_without_taxes').html(formatCurrency(parseFloat(summaryData.summary.total_price_without_tax - summaryData.summary.convenience_fee), currency_format, currency_sign, currency_blank)); + // $('#total_service_products').html(formatCurrency(parseFloat(summaryData.summary.total_service_products), currency_format, currency_sign, currency_blank)); $('#total_taxes').html(formatCurrency(parseFloat(summaryData.summary.total_tax), currency_format, currency_sign, currency_blank)); $('#total_with_taxes').html(formatCurrency(parseFloat(summaryData.summary.total_price), currency_format, currency_sign, currency_blank)); } diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 63a271ecd..fd5459c4b 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -2787,6 +2787,35 @@ public function ajaxProcessAddProductOnOrder() $this->context->cart = $cart; $this->context->customer = new Customer($order->id_customer); + // always add taxes even if not displayed to the customer + $use_taxes = true; + $initial_product_price_tax_incl = Product::getPriceStatic( + $product->id, + $use_taxes, + isset($combination) ? $combination->id : null, + 2, + null, + false, + true, + 1, + false, + $order->id_customer, + $cart->id, + $order->id_address_tax + ); + + // create feature price if needed + $createFeaturePrice = $product_informations['product_price_tax_incl'] != $initial_product_price_tax_incl; + $featurePriceParams = array(); + if ($createFeaturePrice) { + $featurePriceParams = array( + 'id_cart' => $this->context->cart->id, + 'id_guest' => $this->context->cookie->id_guest, + 'price' => $product_informations['product_price_tax_excl'], + 'id_product' => $product->id, + ); + } + /*By Webkul to make entries in HotelCartBookingData */ $hotel_room_info_arr = $hotel_room_data['rm_data'][$idProduct]['data']['available']; $chkQty = 0; @@ -2831,48 +2860,6 @@ public function ajaxProcessAddProductOnOrder() } } /*END*/ - // always add taxes even if there are not displayed to the customer - $use_taxes = true; - - $initial_product_price_tax_incl = Product::getPriceStatic( - $product->id, - $use_taxes, - isset($combination) ? $combination->id : null, - 2, - null, - false, - true, - 1, - false, - $order->id_customer, - $cart->id, - $order->id_address_tax - ); - - // Creating specific price if needed - if ($product_informations['product_price_tax_incl'] != $initial_product_price_tax_incl) { - $specific_price = new SpecificPrice(); - $specific_price->id_shop = 0; - $specific_price->id_shop_group = 0; - $specific_price->id_currency = 0; - $specific_price->id_country = 0; - $specific_price->id_group = 0; - $specific_price->id_customer = $order->id_customer; - $specific_price->id_product = $product->id; - if (isset($combination)) { - $specific_price->id_product_attribute = $combination->id; - } else { - $specific_price->id_product_attribute = 0; - } - $specific_price->price = $product_informations['product_price_tax_excl']; - $specific_price->from_quantity = 1; - $specific_price->reduction = 0; - $specific_price->reduction_type = 'amount'; - $specific_price->reduction_tax = 0; - $specific_price->from = '0000-00-00 00:00:00'; - $specific_price->to = '0000-00-00 00:00:00'; - $specific_price->add(); - } // Add product to cart $update_quantity = $cart->updateQty( @@ -3181,7 +3168,8 @@ public function ajaxProcessAddProductOnOrder() } // delete cart feature prices after room addition success - HotelRoomTypeFeaturePricing::deleteByIdCart($cart->id); + HotelRoomTypeFeaturePricing::deleteByIdCart($this->context->cart->id); + die(json_encode(array( 'result' => true, //'view' => $this->createTemplate('_product_line.tpl')->fetch(),