Merge branch 'webkul:develop' into gli-779

This commit is contained in:
Sumit Panwar
2023-03-28 18:57:29 +05:30
committed by GitHub
20 changed files with 221 additions and 84 deletions

View File

@@ -202,6 +202,19 @@ $(document).ready(function () {
</div>
{if isset($pack) && $pack->isPack($product->id)}<p class="col-lg-9 col-lg-offset-3 help-block">{l s='The sum of prices of the products in the pack is %s%s%s' sprintf=[$currency->prefix,{toolsConvertPrice price=$pack->noPackPrice($product->id)|string_format:$priceDisplayPrecisionFormat},$currency->suffix]}</p>{/if}
</div>
<div class="form-group">
<label class="control-label col-lg-3" for="service_product_type">
<span class="label-tooltip" data-toggle="tooltip" title="{l s='Select whether price for this service will be added for each day of the booking or price will be added to the entire date range of the booking'}">
{l s='Per calculation method'}
<span>
</label>
<div class="col-lg-4">
<select name="price_calculation_method" id="price_calculation_method">
<option value="{Product::PRICE_CALCULATION_METHOD_PER_BOOKING}" {if $product->price_calculation_method == Product::PRICE_CALCULATION_METHOD_PER_BOOKING}selected="selected"{/if} >{l s='Add price once for the booking range'}</option>
<option value="{Product::PRICE_CALCULATION_METHOD_PER_DAY}" {if $product->price_calculation_method == Product::PRICE_CALCULATION_METHOD_PER_DAY}selected="selected"{/if} >{l s='Add price for each day of booking'}</option>
</select>
</div>
</div>
{* As no use in QloApps currently so commented *}
{* <div class="form-group">
<div class="col-lg-1"><span class="pull-right">{include file="controllers/products/multishop/checkbox.tpl" field="unit_price" type="unit_price"}</span></div>

View File

@@ -31,8 +31,8 @@
<thead>
<tr>
<th>{l s='Name'}</th>
<th>{l s='Unit price'}</th>
<th>{l s='Total price'}</th>
<th>{l s='Unit Price'}</th>
<th>{l s='Total Price'}</th>
<th class="text-right">{l s='Action'}</th>
</tr>
</thead>
@@ -127,8 +127,8 @@
<thead>
<tr>
<th>{l s='Name'}</th>
<th>{l s='Unit price'}</th>
<th class="text-right">{l s='Total price'}</th>
<th>{l s='Unit Price'}</th>
<th class="text-right">{l s='Total Price'}</th>
</tr>
</thead>
<tbody>
@@ -138,7 +138,7 @@
<td>
{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}
</td>
<td class="text-right">{displayPrice price=$demand['total_price_tax_excl'] currency=$orderCurrency}</td>

View File

@@ -33,7 +33,8 @@
<th>{l s='Name'}</th>
<th></th>
<th class="fixed-width-md">{l s='Quantity'}</th>
<th>{l s='Price'}</th>
<th>{l s='Unit Price'}</th>
<th>{l s='Total Price'}</th>
<th class="text-right">{l s='Action'}</th>
</tr>
</thead>
@@ -61,6 +62,12 @@
--
{/if}
</td>
<td>
{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}
</td>
<td>{displayPrice price=$service['total_price_tax_excl']|escape:'html':'UTF-8' currency=$orderCurrency}</td>
<td><a class="btn btn-danger pull-right del_room_additional_service" data-id_room_type_service_product_order_detail="{$service['id_room_type_service_product_order_detail']}" href="#"><i class="icon-trash"></i></a></td>
</tr>
@@ -106,7 +113,7 @@
{/if}
</td>
<td>
{if $product.allow_multiple_quantity}
{if $product['allow_multiple_quantity']}
<div class="qty_container">
<input type="number" class="form-control qty" min="1" id="qty_{$product['id_product']|escape:'html':'UTF-8'}" name="service_qty[{$product['id_product']|escape:'html':'UTF-8'}]" data-id-product="{$product.id_product|escape:'html':'UTF-8'}" value="1">
</div>
@@ -115,7 +122,10 @@
{/if}
</td>
<td class="text-right">
{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}
</td>
</tr>
{/foreach}
@@ -136,6 +146,7 @@
<th>{l s='ID'}</th>
<th>{l s='Name'}</th>
<th></th>
<th>{l s='Unit Price'}</th>
<th class="text-right">{l s='Total Price'}</th>
</tr>
</thead>
@@ -154,6 +165,12 @@
<span class="badge badge-info label">{l s='Auto added'}</span>
{/if}
</td>
<td>
{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}
</td>
<td class="text-right">
{displayPrice price=$service['total_price_tax_excl'] currency=$orderCurrency}
</td>

View File

@@ -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`,

View File

@@ -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()
*/

View File

@@ -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);

View File

@@ -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')) {

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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,

View File

@@ -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`),

View File

@@ -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'];
}

View File

@@ -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']);

View File

@@ -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;

View File

@@ -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'],
),

View File

@@ -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;
}
}

View File

@@ -73,7 +73,9 @@
</div>
</div>
<div class="col-xs-4">
<p><span class="pull-right extra_demand_option_price">{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}</span></p>
<p class="pull-right">
<span class="extra_demand_option_price">{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}</span>{if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY}{l s='/Night'}{/if}
</p>
</div>
</div>
{/foreach}
@@ -130,7 +132,8 @@
</div>
<div class="col-xs-4">
{if ($product.show_price && !isset($restricted_country_mode)) || isset($groups)}
<span class="pull-right">{if !$priceDisplay}{convertPrice price=$product.price_tax_incl}{else}{convertPrice price=$product.price_tax_exc}{/if}</span>
<span class="pull-right">{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}</span>
{/if}
</div>
</div>

View File

@@ -44,7 +44,7 @@
<div class="col-sm-12 service_product_action_block">
{if !$PS_CATALOG_MODE && !$order_date_restrict && ($product.show_price && !isset($restricted_country_mode))}
<span class="service-product-price">
{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}<span class="price-label">{l s='/Night'}</span>{/if}
</span>
{/if}

View File

@@ -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;

View File

@@ -370,7 +370,7 @@
</div>
{/if}
<div class="col-xs-11 demand_adv_option_block">
<p>{$demand['name']|escape:'html':'UTF-8'} {if $product->show_price && !isset($restricted_country_mode) && !$PS_CATALOG_MODE}<span class="pull-right"><span class="extra_demand_option_price">{convertPrice price = $demand['price']}</span>{if $demand['price_calc_method'] == $WK_PRICE_CALC_METHOD_EACH_DAY}{l s='/night'}{/if}</span>{/if}</p>
<p>{$demand['name']|escape:'html':'UTF-8'} {if $product->show_price && !isset($restricted_country_mode) && !$PS_CATALOG_MODE}<span class="pull-right"><span class="extra_demand_option_price">{convertPrice price = $demand['price']}</span>{if $demand['price_calc_method'] == $WK_PRICE_CALC_METHOD_EACH_DAY}{l s='/Night'}{/if}</span>{/if}</p>
{if isset($demand['adv_option']) && $demand['adv_option']}
<select class="id_option">
{foreach $demand['adv_option'] as $idOption => $option}