Merge pull request #1261 from sumitwebkul/order-detail-issues

Fixed: Issues in Admin Order detail page in back-office
This commit is contained in:
Rohit Jain
2024-10-04 19:15:11 +05:30
committed by GitHub
10 changed files with 1169 additions and 947 deletions

View File

@@ -191,14 +191,14 @@ abstract class PaymentModuleCore extends Module
if (!$this->active) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Module is not active', 3, null, 'Cart', (int)$id_cart, true);
die(Tools::displayError());
die(Tools::displayError('Error in processing order. Payment module is not active.'));
}
// Does order already exists ?
if (Validate::isLoadedObject($this->context->cart) && $this->context->cart->OrderExists() == false) {
if ($secure_key !== false && $secure_key != $this->context->cart->secure_key) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Secure key does not match', 3, null, 'Cart', (int)$id_cart, true);
die(Tools::displayError());
die(Tools::displayError('Error processing order. Secure key does not match.'));
}
// For each package, generate an order

View File

@@ -867,6 +867,12 @@ class OrderCore extends ObjectModel
WHERE ocr.`id_order` = '.(int)$this->id);
}
public function getCartRulesTotal($useTax = false)
{
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(
'SELECT '.($useTax ? 'SUM(ocr.`value`)' : 'SUM(ocr.`value_tax_excl`)').' FROM `'._DB_PREFIX_.'order_cart_rule` ocr WHERE ocr.`id_order` = '.(int)$this->id);
}
public static function getDiscountsCustomer($id_customer, $id_cart_rule)
{
$cache_id = 'Order::getDiscountsCustomer_'.(int)$id_customer.'-'.(int)$id_cart_rule;
@@ -2847,4 +2853,32 @@ class OrderCore extends ObjectModel
return $result;
}
/**
* @param bool $useTax: if true, total with tax, if false, total without tax
* @param bool $withDiscounts: if true, total including discount, if false, total excluding discount
* @return float total of the order
*/
public function getOrderTotal($useTax = true, $withDiscounts = true)
{
// Get total of rooms and services
if ($useTax) {
$totalRoomsAndServices = $this->getTotalProductsWithTaxes();
} else {
$totalRoomsAndServices = $this->getTotalProductsWithoutTaxes();
}
// Get total of extra demands
$objBookingDemand = new HotelBookingDemands();
$totalExtraDemands = $objBookingDemand->getRoomTypeBookingExtraDemands($this->id, 0, 0, 0, 0, 0, 1, $useTax);
// Get cart rules total
$orderTotalDiscount = $this->getCartRulesTotal($useTax);
// Update order with new amounts after removing cart rule
$totalOrder = ($totalExtraDemands + $totalRoomsAndServices) - $orderTotalDiscount;
$totalOrder = $totalOrder > 0 ? $totalOrder : 0;
return $totalOrder;
}
}

View File

@@ -310,8 +310,11 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
$this->context = Context::getContext();
$cart_htl_data = array();
$service_product_data = array();
$room_extra_demands = array();
$room_additinal_services = array();
if (Module::isInstalled('hotelreservationsystem')) {
$obj_htl_bk_dtl = new HotelBookingDetail();
$obj_rm_type = new HotelRoomType();
$objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail();
@@ -319,11 +322,6 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
$customer = new Customer($this->order->id_customer);
if (!empty($order_details)) {
$processed_product = array();
$cart_htl_data = array();
$service_product_data = array();
$room_extra_demands = array();
$room_additinal_services = array();
$totalDemandsPriceTE = 0;
$totalDemandsPriceTI = 0;
foreach ($order_details as $type_key => $type_value) {