diff --git a/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl b/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl
index 5b02687c8..001ab6c69 100644
--- a/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl
+++ b/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl
@@ -31,8 +31,8 @@
@@ -138,7 +138,7 @@
{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='/ night'}
{/if}
{displayPrice price=$demand['total_price_tax_excl'] currency=$orderCurrency}
diff --git a/admin/themes/default/template/controllers/orders/_room_services_block.tpl b/admin/themes/default/template/controllers/orders/_room_services_block.tpl
index eec75f15b..c0b3ef515 100644
--- a/admin/themes/default/template/controllers/orders/_room_services_block.tpl
+++ b/admin/themes/default/template/controllers/orders/_room_services_block.tpl
@@ -33,7 +33,8 @@
{l s='Name'}
{l s='Quantity'}
- {l s='Price'}
+ {l s='Unit Price'}
+ {l s='Total Price'}
{l s='Action'}
@@ -61,6 +62,12 @@
--
{/if}
+
+ {displayPrice price=$service['unit_price_tax_excl'] currency=$orderCurrency}
+ {if $service['product_price_calculation_method'] == Product::PRICE_CALCULATION_METHOD_PER_DAY}
+ {l s='/ night'}
+ {/if}
+
{displayPrice price=$service['total_price_tax_excl']|escape:'html':'UTF-8' currency=$orderCurrency}
@@ -106,7 +113,7 @@
{/if}
- {if $product.allow_multiple_quantity}
+ {if $product['allow_multiple_quantity']}
@@ -115,7 +122,10 @@
{/if}
- {convertPrice price=$product.price_tax_exc}
+ {convertPrice price=$product['price_tax_exc']}
+ {if $product['price_calculation_method'] == Product::PRICE_CALCULATION_METHOD_PER_DAY}
+ {l s='/ night'}
+ {/if}
{/foreach}
@@ -136,6 +146,7 @@
{l s='ID'}
{l s='Name'}
+ {l s='Unit Price'}
{l s='Total Price'}
@@ -154,6 +165,12 @@
{l s='Auto added'}
{/if}
+
+ {displayPrice price=$service['unit_price_tax_excl'] currency=$orderCurrency}
+ {if $service['product_price_calculation_method'] == Product::PRICE_CALCULATION_METHOD_PER_DAY}
+ {l s='/ night'}
+ {/if}
+
{displayPrice price=$service['total_price_tax_excl'] currency=$orderCurrency}
diff --git a/classes/Cart.php b/classes/Cart.php
index c371c2804..3e6443968 100644
--- a/classes/Cart.php
+++ b/classes/Cart.php
@@ -532,7 +532,7 @@ class CartCore extends ObjectModel
$sql = new DbQuery();
// Build SELECT
- $sql->select('cp.`id_product_attribute`, cp.`id_product`, cp.`quantity` AS cart_quantity, cp.id_shop, pl.`name`, p.`is_virtual`, p.`booking_product`, p.`service_product_type`, p.`auto_add_to_cart`, p.`price_addition_type`, product_shop.`allow_multiple_quantity`,
+ $sql->select('cp.`id_product_attribute`, cp.`id_product`, cp.`quantity` AS cart_quantity, cp.id_shop, pl.`name`, p.`is_virtual`, p.`booking_product`, p.`service_product_type`, p.`auto_add_to_cart`, p.`price_addition_type`, product_shop.`allow_multiple_quantity`, product_shop.`price_calculation_method`,
pl.`description_short`, pl.`available_now`, pl.`available_later`, product_shop.`id_category_default`, p.`id_supplier`,
p.`id_manufacturer`, product_shop.`on_sale`, product_shop.`ecotax`, product_shop.`additional_shipping_cost`,
product_shop.`available_for_order`, product_shop.`price`, product_shop.`active`, product_shop.`unity`, product_shop.`unit_price_ratio`,
diff --git a/classes/Product.php b/classes/Product.php
index c0ffb8dbe..5be2d2244 100644
--- a/classes/Product.php
+++ b/classes/Product.php
@@ -80,6 +80,9 @@ class ProductCore extends ObjectModel
/** @var bool max allowed quantities */
public $max_quantity;
+ /** @var int price calculation method */
+ public $price_calculation_method;
+
/** @var string available_now */
public $available_now;
@@ -310,6 +313,7 @@ class ProductCore extends ObjectModel
'minimal_quantity' => array('type' => self::TYPE_INT, 'shop' => true, 'validate' => 'isUnsignedInt'),
'allow_multiple_quantity' => array('type' => self::TYPE_BOOL, 'shop' => true, 'validate' => 'isBool'),
'max_quantity' => array('type' => self::TYPE_INT, 'shop' => true, 'validate' => 'isUnsignedInt'),
+ 'price_calculation_method' => array('type' => self::TYPE_INT, 'shop' => true, 'validate' => 'isUnsignedId'),
'price' => array('type' => self::TYPE_FLOAT, 'shop' => true, 'validate' => 'isPrice', 'required' => true),
'wholesale_price' => array('type' => self::TYPE_FLOAT, 'shop' => true, 'validate' => 'isPrice'),
'unity' => array('type' => self::TYPE_STRING, 'shop' => true, 'validate' => 'isString'),
@@ -508,6 +512,9 @@ 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;
+
public function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null)
{
@@ -880,6 +887,14 @@ class ProductCore extends ObjectModel
), 'id_product = '.(int)$id_product);
}
+ public static function getProductPriceCalculation($id_product) {
+ return Db::getInstance()->getValue(
+ 'SELECT product_shop.`price_calculation_method`
+ FROM `'._DB_PREFIX_.'product` p '.Shop::addSqlAssociation('product', 'p').'
+ WHERE p.`id_product` = '.(int)$id_product
+ );
+ }
+
/**
* @see ObjectModel::validateField()
*/
diff --git a/classes/order/OrderDetail.php b/classes/order/OrderDetail.php
index 83e4ab2d2..cfda5704a 100644
--- a/classes/order/OrderDetail.php
+++ b/classes/order/OrderDetail.php
@@ -107,6 +107,9 @@ class OrderDetailCore extends ObjectModel
/** @var bool */
public $product_allow_multiple_quantity;
+ /** @var int */
+ public $product_price_calculation_method;
+
/** @var string */
public $product_ean13;
@@ -198,6 +201,7 @@ class OrderDetailCore extends ObjectModel
'product_auto_add' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'product_price_addition_type' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'product_allow_multiple_quantity' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
+ 'product_price_calculation_method' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'product_ean13' => array('type' => self::TYPE_STRING, 'validate' => 'isEan13'),
'product_upc' => array('type' => self::TYPE_STRING, 'validate' => 'isUpc'),
'product_reference' => array('type' => self::TYPE_STRING, 'validate' => 'isReference'),
@@ -657,6 +661,7 @@ class OrderDetailCore extends ObjectModel
$this->product_auto_add = $product['auto_add_to_cart'];
$this->product_price_addition_type = $product['price_addition_type'];
$this->product_allow_multiple_quantity = $product['allow_multiple_quantity'];
+ $this->product_price_calculation_method = $product['price_calculation_method'];
$this->setVirtualProductInformation($product);
$this->checkProductStock($product, $id_order_state);
diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php
index 8a14f7868..5f2f2f568 100644
--- a/controllers/admin/AdminOrdersController.php
+++ b/controllers/admin/AdminOrdersController.php
@@ -5073,28 +5073,36 @@ class AdminOrdersControllerCore extends AdminController
$totalPriceChangeTaxExcl = 0;
$totalPriceChangeTaxIncl = 0;
foreach ($productList as &$product) {
- $totalPriceChangeTaxExcl += $totalPriceTaxExcl = $objRoomTypeServiceProductPrice->getProductPrice(
+ $totalPriceChangeTaxExcl += $totalPriceTaxExcl = $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
$roomInfo['id'],
$product['cart_quantity'],
+ $objHotelBookingDetail->date_from,
+ $objHotelBookingDetail->date_to,
false
);
- $totalPriceChangeTaxIncl += $totalPriceTaxIncl = $objRoomTypeServiceProductPrice->getProductPrice(
+ $totalPriceChangeTaxIncl += $totalPriceTaxIncl = $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
$roomInfo['id'],
$product['cart_quantity'],
+ $objHotelBookingDetail->date_from,
+ $objHotelBookingDetail->date_to,
true
);
- $unitPriceTaxExcl = $objRoomTypeServiceProductPrice->getProductPrice(
+ $unitPriceTaxExcl = $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
$roomInfo['id'],
1,
+ $objHotelBookingDetail->date_from,
+ $objHotelBookingDetail->date_to,
false
);
- $unitPriceTaxIncl = $objRoomTypeServiceProductPrice->getProductPrice(
+ $unitPriceTaxIncl = $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
$roomInfo['id'],
1,
+ $objHotelBookingDetail->date_from,
+ $objHotelBookingDetail->date_to,
true
);
switch (Configuration::get('PS_ROUND_TYPE')) {
diff --git a/controllers/front/GuestTrackingController.php b/controllers/front/GuestTrackingController.php
index 0ce9722ea..dca2c4266 100644
--- a/controllers/front/GuestTrackingController.php
+++ b/controllers/front/GuestTrackingController.php
@@ -228,7 +228,6 @@ class GuestTrackingControllerCore extends FrontController
$total_demands_price_ti = 0;
$total_convenience_fee_te = 0;
$total_convenience_fee_ti = 0;
- // ddd($orderProducts);
foreach ($orderProducts as $type_key => $type_value) {
if (in_array($type_value['product_id'], $processedProducts)) {
continue;
diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php
index 910d08ad3..ec4be6647 100644
--- a/controllers/front/ProductController.php
+++ b/controllers/front/ProductController.php
@@ -701,7 +701,14 @@ class ProductControllerCore extends FrontController
}
$product['name'] = $objServiceProduct->name;
$product['allow_multiple_quantity'] = $objServiceProduct->allow_multiple_quantity;
- $productPrice = $objRoomTypeServiceProductPrice->getProductPrice($product['id_product'], $idProduct, $product['quantity'], $useTax);
+ $productPrice = $objRoomTypeServiceProductPrice->getServicePrice(
+ $product['id_product'],
+ $idProduct,
+ $product['quantity'],
+ $dateFrom,
+ $dateTo,
+ $useTax
+ );
$product['price'] = $productPrice;
$serviceProductsPrice += $productPrice;
}
diff --git a/install/data/db_structure.sql b/install/data/db_structure.sql
index 69c631d36..de57c4024 100644
--- a/install/data/db_structure.sql
+++ b/install/data/db_structure.sql
@@ -1254,6 +1254,7 @@ CREATE TABLE `PREFIX_order_detail` (
`product_auto_add` tinyint(1) NOT NULL DEFAULT '0',
`product_price_addition_type` tinyint(1) NOT NULL DEFAULT '0',
`product_allow_multiple_quantity` tinyint(1) unsigned NOT NULL DEFAULT '1',
+ `product_price_calculation_method` tinyint(1) unsigned NOT NULL DEFAULT '1',
`product_ean13` varchar(13) DEFAULT NULL,
`product_upc` varchar(12) DEFAULT NULL,
`product_reference` varchar(32) DEFAULT NULL,
@@ -1520,6 +1521,7 @@ CREATE TABLE `PREFIX_product` (
`minimal_quantity` int(10) unsigned NOT NULL DEFAULT '1',
`allow_multiple_quantity` tinyint(1) unsigned NOT NULL DEFAULT '1',
`max_quantity` int(10) unsigned NOT NULL DEFAULT '1',
+ `price_calculation_method` tinyint(1) unsigned NOT NULL DEFAULT '1',
`price` decimal(20,6) NOT NULL DEFAULT '0.000000',
`wholesale_price` decimal(20,6) NOT NULL DEFAULT '0.000000',
`unity` varchar(255) DEFAULT NULL,
@@ -1579,6 +1581,7 @@ CREATE TABLE IF NOT EXISTS `PREFIX_product_shop` (
`minimal_quantity` int(10) unsigned NOT NULL DEFAULT '1',
`allow_multiple_quantity` tinyint(1) unsigned NOT NULL DEFAULT '1',
`max_quantity` int(10) unsigned NOT NULL DEFAULT '1',
+ `price_calculation_method` tinyint(1) unsigned NOT NULL DEFAULT '1',
`price` decimal(20,6) NOT NULL DEFAULT '0.000000',
`wholesale_price` decimal(20,6) NOT NULL DEFAULT '0.000000',
`unity` varchar(255) DEFAULT NULL,
diff --git a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php
index dd5f1c62b..9518df583 100644
--- a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php
+++ b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php
@@ -394,12 +394,8 @@ class HotelReservationSystemDb
"CREATE TABLE `"._DB_PREFIX_."htl_room_type_service_product_cart_detail` (
`id_room_type_service_product_cart_detail` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
- `id_room_type` int(11) UNSIGNED NOT NULL,
`id_product` int(11) UNSIGNED NOT NULL,
`quantity` int(11) UNSIGNED NOT NULL,
- `date_from` datetime NOT NULL,
- `date_to` datetime NOT NULL,
- `id_guest` int(11) unsigned NOT NULL,
`id_cart` int(11) unsigned NOT NULL,
`htl_cart_booking_id` int(11) unsigned NOT NULL,
PRIMARY KEY (`id_room_type_service_product_cart_detail`),
diff --git a/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php b/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php
index 476671ea1..29c85977e 100644
--- a/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php
+++ b/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php
@@ -720,12 +720,12 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
}
}
if ($with_auto_room_services) {
- if ($servicesWithTax = RoomTypeServiceProduct::getAutoAddServices($id_product, Product::PRICE_ADDITION_TYPE_WITH_ROOM, true)) {
+ if ($servicesWithTax = RoomTypeServiceProduct::getAutoAddServices($id_product, $date_from, $date_to, Product::PRICE_ADDITION_TYPE_WITH_ROOM, true)) {
foreach($servicesWithTax as $service) {
$totalPrice['total_price_tax_incl'] += $service['price'];
}
}
- if ($servicesWithoutTax = RoomTypeServiceProduct::getAutoAddServices($id_product, Product::PRICE_ADDITION_TYPE_WITH_ROOM, false)) {
+ if ($servicesWithoutTax = RoomTypeServiceProduct::getAutoAddServices($id_product, $date_from, $date_to, Product::PRICE_ADDITION_TYPE_WITH_ROOM, false)) {
foreach($servicesWithoutTax as $service) {
$totalPrice['total_price_tax_excl'] += $service['price'];
}
diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php
index fe105731f..2b4b84113 100644
--- a/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php
+++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php
@@ -115,7 +115,7 @@ class RoomTypeServiceProduct extends ObjectModel
return Db::getInstance()->getValue($sql);
}
- public static function getAutoAddServices($idProduct, $priceAdditionType = null, $useTax = null)
+ public static function getAutoAddServices($idProduct, $dateFrom = null, $dateTo = null, $priceAdditionType = null, $useTax = null)
{
if (Product::isBookingProduct($idProduct)) {
$sql = 'SELECT p.`id_product` FROM `'._DB_PREFIX_.'htl_room_type_service_product` rsp
@@ -127,10 +127,12 @@ class RoomTypeServiceProduct extends ObjectModel
if ($services = Db::getInstance()->executeS($sql)) {
$objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice();
foreach($services as &$service) {
- $service['price'] = $objRoomTypeServiceProductPrice->getProductPrice(
+ $service['price'] = $objRoomTypeServiceProductPrice->getServicePrice(
(int)$service['id_product'],
(int)$idProduct,
1,
+ $dateFrom,
+ $dateTo,
$useTax
);
}
@@ -162,24 +164,30 @@ class RoomTypeServiceProduct extends ObjectModel
$serviceProducts = Product::getProductsProperties($idLang, $serviceProducts);
$objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice();
foreach($serviceProducts as &$serviceProduct) {
- $serviceProduct['price_tax_exc'] = $objRoomTypeServiceProductPrice->getProductPrice(
+ $serviceProduct['price_tax_exc'] = $objRoomTypeServiceProductPrice->getServicePrice(
(int)$serviceProduct['id_product'],
(int)$idProductRoomType,
1,
+ null,
+ null,
false
);
- $serviceProduct['price_tax_incl'] = $objRoomTypeServiceProductPrice->getProductPrice(
+ $serviceProduct['price_tax_incl'] = $objRoomTypeServiceProductPrice->getServicePrice(
(int)$serviceProduct['id_product'],
(int)$idProductRoomType,
1,
+ null,
+ null,
true
);
$useTax = Product::$_taxCalculationMethod == PS_TAX_EXC ? false : true;
- $serviceProduct['price_without_reduction'] = $objRoomTypeServiceProductPrice->getProductPrice(
+ $serviceProduct['price_without_reduction'] = $objRoomTypeServiceProductPrice->getServicePrice(
(int)$serviceProduct['id_product'],
(int)$idProductRoomType,
1,
+ null,
+ null,
$useTax
);
$serviceProduct['images'] = Image::getImages((int)Context::getContext()->language->id, $serviceProduct['id_product']);
diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php
index 5a89f3cf7..53bd5a8a0 100644
--- a/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php
+++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php
@@ -38,11 +38,13 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
public function alreadyExists(
$idProduct,
+ $idCart,
$idHtlCartData
) {
return Db::getInstance()->getValue(
'SELECT `id_room_type_service_product_cart_detail` FROM `'._DB_PREFIX_.'htl_room_type_service_product_cart_detail`
- WHERE `id_product` = '.(int)$idProduct.' AND `htl_cart_booking_id` = '.(int)$idHtlCartData
+ WHERE `id_product` = '.(int)$idProduct.' AND `htl_cart_booking_id` = '.(int)$idHtlCartData.'
+ AND `id_cart` = '.(int)$idCart
);
}
@@ -52,18 +54,28 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
$idCart,
$idHtlCartData
) {
- if ($id_room_type_service_product_cart_detail = $this->alreadyExists($idProduct, $idHtlCartData)) {
+ if ($id_room_type_service_product_cart_detail = $this->alreadyExists($idProduct, $idCart, $idHtlCartData)) {
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail($id_room_type_service_product_cart_detail);
} else {
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
$objRoomTypeServiceProductCartDetail->id_product = $idProduct;
+ $objRoomTypeServiceProductCartDetail->htl_cart_booking_id = $idHtlCartData;
+ $objRoomTypeServiceProductCartDetail->id_cart = $idCart;
}
+
+ $updateQty = $quantity - $objRoomTypeServiceProductCartDetail->quantity;
+
+ if (Product::getProductPriceCalculation($idProduct) == Product::PRICE_CALCULATION_METHOD_PER_DAY) {
+ $objHotelCartBookingData = new HotelCartBookingData($idHtlCartData);
+ $numdays = HotelHelper::getNumberOfDays($objHotelCartBookingData->date_from, $objHotelCartBookingData->date_to);
+ $updateQty *= $numdays;
+
+ }
+ $way = $updateQty > 0 ? 'up' : 'down';
$objRoomTypeServiceProductCartDetail->quantity = $quantity;
- $objRoomTypeServiceProductCartDetail->id_cart = $idCart;
- $objRoomTypeServiceProductCartDetail->htl_cart_booking_id = $idHtlCartData;
if ($objRoomTypeServiceProductCartDetail->save()) {
$objCart = new Cart($idCart);
- return $objCart->updateQty((int)($quantity), $idProduct);
+ return $objCart->updateQty((int)abs($updateQty), $idProduct, null, false, $way);
}
return false;
@@ -106,7 +118,7 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
if ($useTax === null)
$useTax = Product::$_taxCalculationMethod == PS_TAX_EXC ? false : true;
- $sql = 'SELECT rscd.`id_product`, rscd.`quantity`, cbd.`id_product` as `room_type_id_product`
+ $sql = 'SELECT rscd.`id_product`, rscd.`quantity`, cbd.`id_product` as `room_type_id_product`, cbd.`date_from`, cbd.`date_to`
FROM `'._DB_PREFIX_.'htl_cart_booking_data` cbd
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_service_product_cart_detail` rscd ON(rscd.`htl_cart_booking_id` = cbd.`id`)
LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = rscd.`id_product`)
@@ -143,10 +155,12 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
if ($serviceProducts = Db::getInstance()->executeS($sql)) {
foreach ($serviceProducts as $product) {
$qty = $product['quantity'] ? (int)$product['quantity'] : 1;
- $totalPrice += $objRoomTypeServiceProductPrice->getProductPrice(
+ $totalPrice += $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
+ $product['date_from'],
+ $product['date_to'],
$useTax,
false,
$id_address
@@ -172,7 +186,7 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
}
$sql = 'SELECT rscd.`id_product`, rscd.`quantity`, cbd.`id_cart`, p.`auto_add_to_cart`, p.`allow_multiple_quantity`, cbd.`id` as `htl_cart_booking_id`,
- p.`price_addition_type`, cbd.`id_product` as `room_type_id_product`, pl.`name`
+ p.`price_addition_type`, cbd.`id_product` as `room_type_id_product`, pl.`name`, cbd.`date_from`, cbd.`date_to`
FROM `'._DB_PREFIX_.'htl_cart_booking_data` cbd
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_service_product_cart_detail` rscd ON(rscd.`htl_cart_booking_id` = cbd.`id`)
LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = rscd.`id_product`)
@@ -198,26 +212,32 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
$qty = $product['quantity'] ? (int)$product['quantity'] : 1;
if (isset($selectedServiceProducts[$product['id_product']])) {
$selectedServiceProducts[$product['id_product']]['quantity'] += $product['quantity'];
- $selectedServiceProducts[$product['id_product']]['total_price'] += $objRoomTypeServiceProductPrice->getProductPrice(
+ $selectedServiceProducts[$product['id_product']]['total_price'] += $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
+ $product['date_from'],
+ $product['date_to'],
$useTax,
false,
$id_address
);
- $selectedServiceProducts[$product['id_product']]['total_price_tax_excl'] += $objRoomTypeServiceProductPrice->getProductPrice(
+ $selectedServiceProducts[$product['id_product']]['total_price_tax_excl'] += $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
+ $product['date_from'],
+ $product['date_to'],
false,
false,
$id_address
);
- $selectedServiceProducts[$product['id_product']]['total_price_tax_incl'] += $objRoomTypeServiceProductPrice->getProductPrice(
+ $selectedServiceProducts[$product['id_product']]['total_price_tax_incl'] += $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
+ $product['date_from'],
+ $product['date_to'],
true,
false,
$id_address
@@ -225,42 +245,52 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
} else {
$selectedServiceProducts[$product['id_product']] = $product;
- $selectedServiceProducts[$product['id_product']]['unit_price_tax_excl'] = $objRoomTypeServiceProductPrice->getProductPrice(
+ $selectedServiceProducts[$product['id_product']]['unit_price_tax_excl'] = $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
1,
+ null,
+ null,
false,
false,
$id_address
);
- $selectedServiceProducts[$product['id_product']]['unit_price_tax_incl'] = $objRoomTypeServiceProductPrice->getProductPrice(
+ $selectedServiceProducts[$product['id_product']]['unit_price_tax_incl'] = $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
1,
+ null,
+ null,
true,
false,
$id_address
);
- $selectedServiceProducts[$product['id_product']]['total_price'] = $objRoomTypeServiceProductPrice->getProductPrice(
+ $selectedServiceProducts[$product['id_product']]['total_price'] = $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
+ $product['date_from'],
+ $product['date_to'],
$useTax,
false,
$id_address
);
- $selectedServiceProducts[$product['id_product']]['total_price_tax_excl'] = $objRoomTypeServiceProductPrice->getProductPrice(
+ $selectedServiceProducts[$product['id_product']]['total_price_tax_excl'] = $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
+ $product['date_from'],
+ $product['date_to'],
false,
false,
$id_address
);
- $selectedServiceProducts[$product['id_product']]['total_price_tax_incl'] = $objRoomTypeServiceProductPrice->getProductPrice(
+ $selectedServiceProducts[$product['id_product']]['total_price_tax_incl'] = $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
+ $product['date_from'],
+ $product['date_to'],
true,
false,
$id_address
@@ -293,7 +323,7 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
$idLang = Context::getContext()->language->id;
$sql = 'SELECT rscd.`id_product`, rscd.`quantity`, cbd.`id_cart`, cbd.`id` as `htl_cart_booking_id` ,
- cbd.`id_product` as `room_type_id_product`, cbd.`adults`, cbd.`children`';
+ cbd.`id_product` as `room_type_id_product`, cbd.`adults`, cbd.`children`, cbd.`date_from`, cbd.`date_to`';
if (!$getTotalPrice) {
$sql .= ', pl.`name`, cbd.`id_guest`, cbd.`id_customer`, p.`auto_add_to_cart`, p.`price_addition_type`,
cbd.`id_hotel`, cbd.`id_room`, cbd.`date_from`, cbd.`date_to`, cbd.`is_refunded`';
@@ -346,10 +376,12 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
foreach ($serviceProducts as $product) {
if ($getTotalPrice) {
$qty = $product['quantity'] ? (int)$product['quantity'] : 1;
- $totalPrice += $objRoomTypeServiceProductPrice->getProductPrice(
+ $totalPrice += $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
+ $product['date_from'],
+ $product['date_to'],
$useTax,
false,
$id_address
@@ -367,44 +399,54 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
'quantity' => $product['quantity'],
'auto_add_to_cart' => $product['auto_add_to_cart'],
'price_addition_type' => $product['price_addition_type'],
- 'unit_price_tax_excl' => $objRoomTypeServiceProductPrice->getProductPrice(
+ 'unit_price_tax_excl' => $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
1,
+ null,
+ null,
false,
false,
$id_address
),
- 'unit_price_tax_incl' => $objRoomTypeServiceProductPrice->getProductPrice(
+ 'unit_price_tax_incl' => $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
1,
+ null,
+ null,
true,
false,
$id_address
),
);
}
- $selectedServiceProducts[$product['htl_cart_booking_id']]['total_price'] += $objRoomTypeServiceProductPrice->getProductPrice(
+ $selectedServiceProducts[$product['htl_cart_booking_id']]['total_price'] += $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
+ $product['date_from'],
+ $product['date_to'],
$useTax,
false,
$id_address
);
- $selectedServiceProducts[$product['htl_cart_booking_id']]['total_price_tax_excl'] += $objRoomTypeServiceProductPrice->getProductPrice(
+ $selectedServiceProducts[$product['htl_cart_booking_id']]['total_price_tax_excl'] += $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
+ $product['date_from'],
+ $product['date_to'],
false,
false,
$id_address
);
- $selectedServiceProducts[$product['htl_cart_booking_id']]['total_price_tax_incl'] += $objRoomTypeServiceProductPrice->getProductPrice(
+ $selectedServiceProducts[$product['htl_cart_booking_id']]['total_price_tax_incl'] += $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
+ $product['date_from'],
+ $product['date_to'],
true,
false,
$id_address
@@ -428,18 +470,22 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
$selectedServiceProducts[$product['htl_cart_booking_id']]['quantity'] = $product['quantity'];
$selectedServiceProducts[$product['htl_cart_booking_id']]['auto_add_to_cart'] = $product['auto_add_to_cart'];
$selectedServiceProducts[$product['htl_cart_booking_id']]['price_addition_type'] = $product['price_addition_type'];
- $selectedServiceProducts[$product['htl_cart_booking_id']]['unit_price_tax_excl'] = $objRoomTypeServiceProductPrice->getProductPrice(
+ $selectedServiceProducts[$product['htl_cart_booking_id']]['unit_price_tax_excl'] = $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
1,
+ null,
+ null,
false,
false,
$id_address
);
- $selectedServiceProducts[$product['htl_cart_booking_id']]['unit_price_tax_incl'] = $objRoomTypeServiceProductPrice->getProductPrice(
+ $selectedServiceProducts[$product['htl_cart_booking_id']]['unit_price_tax_incl'] = $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
1,
+ null,
+ null,
true,
false,
$id_address
@@ -451,18 +497,22 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
'quantity' => $product['quantity'],
'auto_add_to_cart' => $product['auto_add_to_cart'],
'price_addition_type' => $product['price_addition_type'],
- 'unit_price_tax_excl' => $objRoomTypeServiceProductPrice->getProductPrice(
+ 'unit_price_tax_excl' => $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
1,
+ null,
+ null,
false,
false,
$id_address
),
- 'unit_price_tax_incl' => $objRoomTypeServiceProductPrice->getProductPrice(
+ 'unit_price_tax_incl' => $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
1,
+ null,
+ null,
true,
false,
$id_address
@@ -470,26 +520,32 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
);
}
- $selectedServiceProducts[$product['htl_cart_booking_id']]['total_price'] = $objRoomTypeServiceProductPrice->getProductPrice(
+ $selectedServiceProducts[$product['htl_cart_booking_id']]['total_price'] = $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
+ $product['date_from'],
+ $product['date_to'],
$useTax,
false,
$id_address
);
- $selectedServiceProducts[$product['htl_cart_booking_id']]['total_price_tax_excl'] = $objRoomTypeServiceProductPrice->getProductPrice(
+ $selectedServiceProducts[$product['htl_cart_booking_id']]['total_price_tax_excl'] = $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
+ $product['date_from'],
+ $product['date_to'],
false,
false,
$id_address
);
- $selectedServiceProducts[$product['htl_cart_booking_id']]['total_price_tax_incl'] = $objRoomTypeServiceProductPrice->getProductPrice(
+ $selectedServiceProducts[$product['htl_cart_booking_id']]['total_price_tax_incl'] = $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
$qty,
+ $product['date_from'],
+ $product['date_to'],
true,
false,
$id_address
@@ -507,37 +563,28 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
}
public function updateCartServiceProduct(
- $htl_cart_booking_id,
- $id_product,
+ $idHtlCartData,
+ $idProduct,
$quantity,
- $id_cart,
+ $idCart,
$operator
) {
- $id_room_type_service_product_cart_detail = $this->alreadyExists($id_product, $htl_cart_booking_id);
+ $id_room_type_service_product_cart_detail = $this->alreadyExists($idProduct, $idCart, $idHtlCartData);
if ($operator == 'up') {
- if ($id_room_type_service_product_cart_detail) {
- $objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail($id_room_type_service_product_cart_detail);
- } else {
- $objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
- $objRoomTypeServiceProductCartDetail->id_product = $id_product;
- $objRoomTypeServiceProductCartDetail->htl_cart_booking_id = $htl_cart_booking_id;
- $objRoomTypeServiceProductCartDetail->id_cart = $id_cart;
- }
- $updateQty = $quantity - $objRoomTypeServiceProductCartDetail->quantity;
- $way = $updateQty > 0 ? 'up' : 'down';
- $objRoomTypeServiceProductCartDetail->quantity = $quantity;
- if ($objRoomTypeServiceProductCartDetail->save()) {
- $objCart = new Cart($id_cart);
- return $objCart->updateQty((int)abs($updateQty), $id_product, null, false, $way);
- }
+ return $this->addServiceProductInCart(
+ $idProduct,
+ $quantity,
+ $idCart,
+ $idHtlCartData
+ );
} else {
if ($id_room_type_service_product_cart_detail) {
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail($id_room_type_service_product_cart_detail);
$updateQty = $objRoomTypeServiceProductCartDetail->quantity;
if ($objRoomTypeServiceProductCartDetail->delete()) {
- $objCart = new Cart($id_cart);
- return $objCart->updateQty((int)abs($updateQty), $id_product, null, false, 'down');
+ $objCart = new Cart($idCart);
+ return $objCart->updateQty((int)abs($updateQty), $idProduct, null, false, 'down');
}
} else {
return true;
diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProductOrderDetail.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProductOrderDetail.php
index d1b0a7667..6e6f16e7b 100644
--- a/modules/hotelreservationsystem/classes/RoomTypeServiceProductOrderDetail.php
+++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProductOrderDetail.php
@@ -200,7 +200,8 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel
$sql = 'SELECT rsod.*';
if (!$getTotalPrice) {
- $sql .= ', hbd.`id_product` as `room_type_id_product`, od.`product_allow_multiple_quantity`, hbd.`id_room`, od.`product_auto_add`, od.`product_price_addition_type`';
+ $sql .= ', hbd.`id_product` as `room_type_id_product`, hbd.`id_room`, od.`product_allow_multiple_quantity`,
+ od.`product_auto_add`, od.`product_price_calculation_method`, od.`product_price_addition_type`';
}
$sql .= ' FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_service_product_order_detail` rsod ON(rsod.`id_htl_booking_detail` = hbd.`id`)';
@@ -232,6 +233,9 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel
'allow_multiple_quantity' => $product['product_allow_multiple_quantity'],
'product_auto_add' => $product['product_auto_add'],
'product_price_addition_type' => $product['product_price_addition_type'],
+ 'product_price_calculation_method' => $product['product_price_calculation_method'],
+ 'unit_price_tax_excl' => $product['unit_price_tax_excl'],
+ 'unit_price_tax_incl' => $product['unit_price_tax_incl'],
'total_price_tax_excl' => $product['total_price_tax_excl'],
'total_price_tax_incl' => $product['total_price_tax_incl'],
);
@@ -253,6 +257,9 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel
'allow_multiple_quantity' => $product['product_allow_multiple_quantity'],
'product_auto_add' => $product['product_auto_add'],
'product_price_addition_type' => $product['product_price_addition_type'],
+ 'product_price_calculation_method' => $product['product_price_calculation_method'],
+ 'unit_price_tax_excl' => $product['unit_price_tax_excl'],
+ 'unit_price_tax_incl' => $product['unit_price_tax_incl'],
'total_price_tax_excl' => $product['total_price_tax_excl'],
'total_price_tax_incl' => $product['total_price_tax_incl'],
),
diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProductPrice.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProductPrice.php
index 908bdba0d..ea8879f6e 100644
--- a/modules/hotelreservationsystem/classes/RoomTypeServiceProductPrice.php
+++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProductPrice.php
@@ -83,14 +83,14 @@ class RoomTypeServiceProductPrice extends ObjectModel
);
}
- public function getProductPrice($idProduct, $idProductRoomType, $quantity, $useTax = null, $id_cart = false, $id_address = null, $test= false)
+ public function getServicePrice($idProduct, $idProductRoomType, $quantity, $dateFrom = null, $dateTo = null, $useTax = null, $id_cart = false, $id_address = null, $test= false)
{
if ($useTax === null)
$useTax = Product::$_taxCalculationMethod == PS_TAX_EXC ? false : true;
$id_address = $id_address ? $id_address : Cart::getIdAddressForTaxCalculation($idProductRoomType);
- $price = ProductCore::getPriceStatic(
+ $price = Product::getPriceStatic(
(int)$idProduct,
$useTax,
null,
@@ -111,6 +111,12 @@ class RoomTypeServiceProductPrice extends ObjectModel
(int)$idProductRoomType
);
+ if (Product::getProductPriceCalculation($idProduct) == Product::PRICE_CALCULATION_METHOD_PER_DAY
+ && $dateFrom && $dateTo
+ ) {
+ $price = $price * HotelHelper::getNumberOfDays($dateFrom, $dateTo);
+ }
+
return $price * (int)$quantity;
}
}
diff --git a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl
index f9dab7639..9e01e9a1e 100644
--- a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl
+++ b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl
@@ -73,7 +73,9 @@
-
{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 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}
+
{/foreach}
@@ -130,7 +132,8 @@
{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 !$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}
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 423d6360a..9f4167318 100644
--- a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl
+++ b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl
@@ -44,7 +44,7 @@
{if !$PS_CATALOG_MODE && !$order_date_restrict && ($product.show_price && !isset($restricted_country_mode))}
- {if !$priceDisplay}{convertPrice price=$product.price_tax_incl}{else}{convertPrice price=$product.price_tax_exc}{/if}
+ {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}
diff --git a/themes/hotel-reservation-theme/css/product.css b/themes/hotel-reservation-theme/css/product.css
index 3ce47bf0f..cd1528066 100644
--- a/themes/hotel-reservation-theme/css/product.css
+++ b/themes/hotel-reservation-theme/css/product.css
@@ -1548,6 +1548,9 @@ ul.service-product-nav > li:hover {
font-size: 22px;
line-height: 27.24px;
}
+.service-product-element .service-product-price .price-label{
+ font-size: 14px;
+}
.service-product-element .service-product-actions {
display: flex;
diff --git a/themes/hotel-reservation-theme/product.tpl b/themes/hotel-reservation-theme/product.tpl
index 9f3591739..57cc9df5c 100644
--- a/themes/hotel-reservation-theme/product.tpl
+++ b/themes/hotel-reservation-theme/product.tpl
@@ -370,7 +370,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']}
{foreach $demand['adv_option'] as $idOption => $option}