Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed: Custom price set for a room type in an order at back office is also reflected at front office for same customer #785

Merged
merged 2 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -677,11 +677,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 @@ -3205,6 +3205,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 @@ -3262,49 +3293,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 @@ -3675,7 +3663,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