Merge branch 'develop' into gli-3014
This commit is contained in:
@@ -737,6 +737,7 @@ class MediaCore
|
||||
} else {
|
||||
$content .= Media::packJS($tmp_content);
|
||||
}
|
||||
$content .= ";\n";
|
||||
} else {
|
||||
$compressed_js_files_not_found[] = $file_infos['path'];
|
||||
}
|
||||
|
||||
@@ -3031,7 +3031,8 @@ class ProductCore extends ObjectModel
|
||||
* @param null $specific_price_output If a specific price applies regarding the previous parameters,
|
||||
* this variable is filled with the corresponding SpecificPrice object
|
||||
* @param bool $with_ecotax Insert ecotax in price output.
|
||||
* @param bool $use_group_reduction
|
||||
* @param bool $use_group_reduction @deprecated no longer applied here; call
|
||||
* Product::applyGroupDiscount() explicitly on your final total.
|
||||
* @param Context $context
|
||||
* @param bool $use_customer_price
|
||||
* @return float Product price
|
||||
@@ -3200,7 +3201,8 @@ class ProductCore extends ObjectModel
|
||||
* @param bool $with_ecotax insert ecotax in price output.
|
||||
* @param null $specific_price If a specific price applies regarding the previous parameters,
|
||||
* this variable is filled with the corresponding SpecificPrice object
|
||||
* @param bool $use_group_reduction
|
||||
* @param bool $use_group_reduction @deprecated no longer applied here; call
|
||||
* Product::applyGroupDiscount() explicitly on your final total.
|
||||
* @param int $id_customer
|
||||
* @param bool $use_customer_price
|
||||
* @param int $id_cart
|
||||
@@ -3454,18 +3456,6 @@ class ProductCore extends ObjectModel
|
||||
$price -= $specific_price_reduction;
|
||||
}
|
||||
|
||||
// Group reduction
|
||||
if ($use_group_reduction) {
|
||||
$reduction_from_category = GroupReduction::getValueForProduct($id_product, $id_group);
|
||||
if ($reduction_from_category !== false) {
|
||||
$group_reduction = $price * (float)$reduction_from_category;
|
||||
} else { // apply group reduction if there is no group reduction for this category
|
||||
$group_reduction = (($reduc = Group::getReductionByIdGroup($id_group)) != 0) ? ($price * $reduc / 100) : 0;
|
||||
}
|
||||
|
||||
$price -= $group_reduction;
|
||||
}
|
||||
|
||||
if ($only_reduc) {
|
||||
return Tools::ps_round($specific_price_reduction, $decimals);
|
||||
}
|
||||
@@ -3480,6 +3470,32 @@ class ProductCore extends ObjectModel
|
||||
return self::$_prices[$cache_id];
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the group discount to an already-computed price.
|
||||
* @param float $price The price to discount (tax-incl. or tax-excl., either works).
|
||||
* @param int $id_product
|
||||
* @param int $id_group
|
||||
* @param bool $use_group_reduction
|
||||
* @return float
|
||||
*/
|
||||
public static function applyGroupDiscount($price, $id_product, $id_group, $use_group_reduction = true)
|
||||
{
|
||||
if (!$use_group_reduction) {
|
||||
return $price;
|
||||
}
|
||||
|
||||
$reduction_from_category = GroupReduction::getValueForProduct($id_product, $id_group);
|
||||
if ($reduction_from_category !== false) {
|
||||
$group_reduction = $price * (float)$reduction_from_category;
|
||||
} else { // apply group reduction if there is no group reduction for this category
|
||||
$group_reduction = (($reduc = Group::getReductionByIdGroup($id_group)) != 0) ? ($price * $reduc / 100) : 0;
|
||||
}
|
||||
|
||||
$price -= $group_reduction;
|
||||
|
||||
return $price < 0 ? 0 : $price;
|
||||
}
|
||||
|
||||
public static function convertAndFormatPrice($price, $currency = false, ?Context $context = null)
|
||||
{
|
||||
if (!$context) {
|
||||
@@ -6869,7 +6885,16 @@ class ProductCore extends ObjectModel
|
||||
$price = $price * HotelHelper::getNumberOfDays($dateFrom, $dateTo);
|
||||
}
|
||||
|
||||
return $price * (int)$quantity;
|
||||
$price = $price * (int)$quantity;
|
||||
|
||||
if (!$specificPrice || ($specificPrice['id_cart'] == 0 && $specificPrice['id_htl_cart_booking'] == 0)) {
|
||||
if (!$idGroup || !Validate::isLoadedObject(new Group((int)$idGroup))) {
|
||||
$idGroup = (int)Group::getCurrent()->id;
|
||||
}
|
||||
$price = Product::applyGroupDiscount($price, $idProduct, $idGroup);
|
||||
}
|
||||
return $price;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -522,7 +522,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
if (!$cart_order_exists) {
|
||||
$this->context->cart = $cart;
|
||||
$this->context->currency = new Currency((int)$cart->id_currency);
|
||||
|
||||
$this->context->customer = new Customer((int)$cart->id_customer);
|
||||
// validate cart for removing invalid data from cart before new order creation
|
||||
// remove not linked services with room types from cart if not allowed to book them
|
||||
$this->errors = array_merge(
|
||||
@@ -1106,25 +1106,45 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$objProduct = new Product();
|
||||
$hotelServiceProducts = $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE);
|
||||
$roomTypeServiceProducts = $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE);
|
||||
$serviceProducts = array_merge($roomTypeServiceProducts, $hotelServiceProducts);
|
||||
} else {
|
||||
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
|
||||
$serviceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, false, 2, null);
|
||||
}
|
||||
|
||||
if ($serviceProducts) {
|
||||
foreach ($serviceProducts as $key => $servProduct) {
|
||||
$serviceProducts[$key]['price_tax_exc'] = $servProduct['price'];
|
||||
if (isset($additionalServices[$productLineData['id']])
|
||||
&& in_array($servProduct['id_product'], array_column($additionalServices[$productLineData['id']]['additional_services'], 'id_product'))
|
||||
) {
|
||||
unset($serviceProducts[$key]);
|
||||
if ($serviceProducts = array_merge($roomTypeServiceProducts, $hotelServiceProducts)) {
|
||||
foreach ($serviceProducts as $key => $servProduct) {
|
||||
if (!empty($additionalServices[$productLineData['id']])
|
||||
&& in_array($servProduct['id_product'], array_column($additionalServices[$productLineData['id']]['additional_services'], 'id_product'))
|
||||
) {
|
||||
unset($serviceProducts[$key]);
|
||||
} else {
|
||||
$numDays = 1;
|
||||
if (Product::PRICE_CALCULATION_METHOD_PER_DAY == $servProduct['price_calculation_method']) {
|
||||
$numDays = HotelHelper::getNumberOfDays($dateFrom, $dateTo);
|
||||
}
|
||||
$serviceProducts[$key]['price_tax_exc'] = Product::getServiceProductPrice(
|
||||
$servProduct['id_product'],
|
||||
0,
|
||||
0,
|
||||
$idProduct,
|
||||
false,
|
||||
1,
|
||||
$dateFrom,
|
||||
$dateTo
|
||||
)/$numDays;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
|
||||
if ($serviceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, false, 2, null)) {
|
||||
foreach ($serviceProducts as $key => $servProduct) {
|
||||
if (isset($additionalServices[$productLineData['id']])
|
||||
&& in_array($servProduct['id_product'], array_column($additionalServices[$productLineData['id']]['additional_services'], 'id_product'))
|
||||
) {
|
||||
unset($serviceProducts[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$smartyVars['serviceProducts'] = $serviceProducts;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$smartyVars['serviceProducts'] = $serviceProducts;
|
||||
$objOrderReturn = new OrderReturn();
|
||||
$refundReqBookings = $objOrderReturn->getOrderRefundRequestedBookings($objOrder->id, 0, 1);
|
||||
$smartyVars['refundReqBookings'] = $refundReqBookings;
|
||||
|
||||
@@ -282,6 +282,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
|
||||
$totalPrice['total_price_tax_excl'] = 0;
|
||||
$featureImpactPriceTE = 0;
|
||||
$featureImpactPriceTI = 0;
|
||||
|
||||
$productPriceTI = Product::getPriceStatic((int) $id_product, 1, 0, 6, null, 0, $use_reduc, 1, 0, null, null, null, $nothing, 1, 1, null, 1, 0, 0, $id_group);
|
||||
$productPriceTE = Product::getPriceStatic((int) $id_product, 0, 0, 6, null, 0, $use_reduc, 1, 0, null, null, null, $nothing, 1, 1, null, 1, 0, 0, $id_group);
|
||||
$id_address = HotelRoomType::getHotelIdAddressByIdProduct($id_product);
|
||||
@@ -317,6 +318,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
|
||||
$id_guest,
|
||||
$id_room
|
||||
))) {
|
||||
|
||||
if ($featurePrice['impact_type'] == self::IMPACT_TYPE_PERCENTAGE) {
|
||||
//percentage
|
||||
$featureImpactPriceTE = $productPriceTE * ($featurePrice['impact_value'] / 100);
|
||||
@@ -344,9 +346,16 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
|
||||
$priceWithFeatureTI = 0;
|
||||
$priceWithFeatureTE = 0;
|
||||
}
|
||||
if ((int)$featurePrice['id_cart'] == 0) {
|
||||
$priceWithFeatureTI = Product::applyGroupDiscount($priceWithFeatureTI, $id_product, $id_group);
|
||||
$priceWithFeatureTE = Product::applyGroupDiscount($priceWithFeatureTE, $id_product, $id_group);
|
||||
}
|
||||
$totalPrice['total_price_tax_incl'] += $priceWithFeatureTI;
|
||||
$totalPrice['total_price_tax_excl'] += $priceWithFeatureTE;
|
||||
} else {
|
||||
|
||||
$productPriceTI = Product::applyGroupDiscount($productPriceTI, $id_product, $id_group);
|
||||
$productPriceTE = Product::applyGroupDiscount($productPriceTE, $id_product, $id_group);
|
||||
$totalPrice['total_price_tax_incl'] += $productPriceTI;
|
||||
$totalPrice['total_price_tax_excl'] += $productPriceTE;
|
||||
}
|
||||
@@ -368,6 +377,8 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
|
||||
'occupancy' => $occupancy
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
if ($with_auto_room_services) {
|
||||
if ($id_cart && $id_room) {
|
||||
$objHotelCartBookingData = new HotelCartBookingData();
|
||||
|
||||
@@ -144,7 +144,8 @@ class RoomTypeServiceProductPrice extends ObjectModel
|
||||
$idHotelAddress
|
||||
);
|
||||
|
||||
return $price * (int)$quantity;
|
||||
$price = $price * (int)$quantity;
|
||||
return Product::applyGroupDiscount($price, $idProduct, (int)Group::getCurrent()->id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user