Skip to content

Commit

Permalink
Merge pull request #785 from abhishek-webkul/gli-1466
Browse files Browse the repository at this point in the history
Fixed: Custom price set for a room type in an order at back office is also reflected at front office for same customer
  • Loading branch information
rohit053 authored Mar 18, 2024
2 parents 86c69a0 + 170ad2b commit 2db6340
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 48 deletions.
8 changes: 4 additions & 4 deletions admin/themes/default/template/controllers/orders/form.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -712,11 +712,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));
}
Expand Down
77 changes: 33 additions & 44 deletions controllers/admin/AdminOrdersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3338,6 +3338,37 @@ 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;
$this->context->currency = new Currency($order->id_currency);

$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;
Expand Down Expand Up @@ -3395,49 +3426,6 @@ public function ajaxProcessAddProductOnOrder()
}
}
/*END*/
// always add taxes even if there are not displayed to the customer
$use_taxes = true;
$this->context->currency = new Currency($order->id_currency);

$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 = $order->id_currency;
$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(
Expand Down Expand Up @@ -3808,7 +3796,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(),
Expand Down

0 comments on commit 2db6340

Please sign in to comment.