Fixed: Fix service product price calculation in Order and Cart controllers
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
var can_edit_booking_carts = {if isset($can_edit_booking_carts) && $can_edit_booking_carts}true{else}false{/if};
|
||||
var can_add_addresses = {if isset($can_add_addresses) && $can_add_addresses}true{else}false{/if};
|
||||
var admin_order_tab_link = "{$link->getAdminLink('AdminOrders')|addslashes}";
|
||||
var new_service_pcm_once_for_booking = {Product::PRICE_CALCULATION_METHOD_ONCE_FOR_BOOKING|intval};
|
||||
var changed_shipping_price = false;
|
||||
var shipping_price_selected_carrier = '';
|
||||
var current_index = '{$current|escape:'html':'UTF-8'}&token={$token|escape:'html':'UTF-8'}';
|
||||
@@ -53,6 +54,13 @@
|
||||
var priceDisplayPrecision = {$smarty.const._PS_PRICE_DISPLAY_PRECISION_|intval};
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).on('change', '#add_new_room_services_form select[name="price_calculation_type"]', function() {
|
||||
if ($(this).val() == new_service_pcm_once_for_booking) {
|
||||
$('#new_service_pcm_days_container').hide();
|
||||
} else {
|
||||
$('#new_service_pcm_days_container').show();
|
||||
}
|
||||
});
|
||||
|
||||
$('.total_taxes_price_info img').tooltip({
|
||||
content: function () {
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
<script type="text/javascript">
|
||||
var admin_order_tab_link = "{$link->getAdminLink('AdminOrders')|addslashes}";
|
||||
var rooms_reallocation_url = "{$link->getAdminLink('AdminOrders')|addslashes}";
|
||||
var new_service_pcm_once_for_booking = {Product::PRICE_CALCULATION_METHOD_ONCE_FOR_BOOKING|intval};
|
||||
var id_order = {$order->id};
|
||||
var id_lang = {$current_id_lang};
|
||||
var id_currency = {$order->id_currency};
|
||||
|
||||
@@ -150,23 +150,36 @@
|
||||
<div class="row form-group">
|
||||
<div class="col-sm-6">
|
||||
<label class="control-label required">{l s='Price calculation method'}</label>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" id="pcm_checkin" name="new_service_price_calc_method[]" value="{Product::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY|intval}">
|
||||
{l s='Check-in day'}
|
||||
</label>
|
||||
</div>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" id="pcm_checkout" name="new_service_price_calc_method[]" value="{Product::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY|intval}">
|
||||
{l s='Check-out day'}
|
||||
</label>
|
||||
</div>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" id="pcm_duringstay" name="new_service_price_calc_method[]" value="{Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY|intval}"/>
|
||||
{l s='During-stay days'}
|
||||
</label>
|
||||
<select id="new_service_pcm_type" name="price_calculation_type">
|
||||
<option value="{Product::PRICE_CALCULATION_METHOD_ONCE_FOR_BOOKING|intval}" selected="selected">{l s='Once for the booking range'}</option>
|
||||
<option value="0">{l s='For each day of the booking'}</option>
|
||||
</select>
|
||||
<div id="new_service_pcm_days_container" style="margin-top: 10px; display:none;">
|
||||
<div class="row">
|
||||
<div class="col-sm-3">
|
||||
<label class="control-label required">{l s='Applied on:'}</label>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" id="pcm_checkin" name="new_service_price_calc_method[]" value="{Product::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY|intval}">
|
||||
{l s='Check-in day'}
|
||||
</label>
|
||||
</div>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" id="pcm_checkout" name="new_service_price_calc_method[]" value="{Product::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY|intval}">
|
||||
{l s='Check-out day'}
|
||||
</label>
|
||||
</div>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" id="pcm_duringstay" name="new_service_price_calc_method[]" value="{Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY|intval}"/>
|
||||
{l s='During-stay days'}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
|
||||
@@ -226,23 +226,36 @@
|
||||
<div class="row form-group">
|
||||
<div class="col-sm-6">
|
||||
<label class="control-label required">{l s='Price calculation method'}</label>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" id="pcm_checkin" name="new_service_price_calc_method[]" value="{Product::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY|intval}">
|
||||
{l s='Check-in day'}
|
||||
</label>
|
||||
</div>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" id="pcm_checkout" name="new_service_price_calc_method[]" value="{Product::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY|intval}">
|
||||
{l s='Check-out day'}
|
||||
</label>
|
||||
</div>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" id="pcm_duringstay" name="new_service_price_calc_method[]" value="{Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY|intval}"/>
|
||||
{l s='During-stay days'}
|
||||
</label>
|
||||
<select id="new_service_pcm_type" name="price_calculation_type">
|
||||
<option value="{Product::PRICE_CALCULATION_METHOD_ONCE_FOR_BOOKING|intval}" selected="selected">{l s='Once for the booking range'}</option>
|
||||
<option value="0">{l s='For each day of the booking'}</option>
|
||||
</select>
|
||||
<div id="new_service_pcm_days_container" style="margin-top: 10px; display:none;">
|
||||
<div class="row">
|
||||
<div class="col-sm-3">
|
||||
<label class="control-label required">{l s='Applied on:'}</label>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" id="pcm_checkin" name="new_service_price_calc_method[]" value="{Product::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY|intval}">
|
||||
{l s='Check-in day'}
|
||||
</label>
|
||||
</div>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" id="pcm_checkout" name="new_service_price_calc_method[]" value="{Product::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY|intval}">
|
||||
{l s='Check-out day'}
|
||||
</label>
|
||||
</div>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" id="pcm_duringstay" name="new_service_price_calc_method[]" value="{Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY|intval}"/>
|
||||
{l s='During-stay days'}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
|
||||
@@ -1346,9 +1346,10 @@ class AdminCartsControllerCore extends AdminController
|
||||
$objCart = new Cart($objHtlCartBooking->id_cart);
|
||||
$name = trim(Tools::getValue('new_service_name'));
|
||||
$price = Tools::getValue('new_service_price');
|
||||
$priceCalcMethod = Tools::getValue('new_service_price_calc_method');
|
||||
if (is_array($priceCalcMethod)) {
|
||||
$priceCalcMethod = array_sum(array_map('intval', $priceCalcMethod));
|
||||
if (Tools::getValue('price_calculation_type') == Product::PRICE_CALCULATION_METHOD_ONCE_FOR_BOOKING) {
|
||||
$priceCalcMethod = Product::PRICE_CALCULATION_METHOD_ONCE_FOR_BOOKING;
|
||||
} elseif (is_array(Tools::getValue('new_service_price_calc_method'))) {
|
||||
$priceCalcMethod = array_sum(array_map('intval', Tools::getValue('new_service_price_calc_method')));
|
||||
}
|
||||
$priceAdditionType = Tools::getValue('new_service_price_addition_type');
|
||||
$productQty = Tools::getValue('new_service_qty');
|
||||
@@ -1384,7 +1385,7 @@ class AdminCartsControllerCore extends AdminController
|
||||
|
||||
if (empty($priceCalcMethod)) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = Tools::displayError('Please select at least one price calculation method.');
|
||||
$response['errors'][] = Tools::displayError('Please select at least one day to apply the price calculation method.');
|
||||
} elseif (
|
||||
!Validate::isUnsignedInt($priceCalcMethod)) {
|
||||
$response['hasError'] = true;
|
||||
|
||||
@@ -8353,9 +8353,10 @@ class AdminOrdersControllerCore extends AdminController
|
||||
)) {
|
||||
$name = trim(Tools::getValue('new_service_name'));
|
||||
$price = Tools::getValue('new_service_price');
|
||||
$priceCalcMethod = Tools::getValue('new_service_price_calc_method');
|
||||
if (is_array($priceCalcMethod)) {
|
||||
$priceCalcMethod = array_sum(array_map('intval', $priceCalcMethod));
|
||||
if (Tools::getValue('price_calculation_type') == Product::PRICE_CALCULATION_METHOD_ONCE_FOR_BOOKING) {
|
||||
$priceCalcMethod = Product::PRICE_CALCULATION_METHOD_ONCE_FOR_BOOKING;
|
||||
} elseif (is_array(Tools::getValue('new_service_price_calc_method'))) {
|
||||
$priceCalcMethod = array_sum(array_map('intval', Tools::getValue('new_service_price_calc_method')));
|
||||
}
|
||||
$priceAdditionType = Tools::getValue('new_service_price_addition_type');
|
||||
$productQty = Tools::getValue('new_service_qty');
|
||||
@@ -8392,7 +8393,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
|
||||
if (empty($priceCalcMethod)) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = Tools::displayError('Please select at least one price calculation method.');
|
||||
$response['errors'][] = Tools::displayError('Please select at least one day to apply the price calculation method.');
|
||||
} elseif (
|
||||
!Validate::isUnsignedInt($priceCalcMethod)) {
|
||||
$response['hasError'] = true;
|
||||
|
||||
@@ -1083,6 +1083,14 @@ $(document).ready(function() {
|
||||
$('#btn_new_room_service').hide();
|
||||
});
|
||||
|
||||
$(document).on('change', '#add_new_room_services_form select[name="price_calculation_type"]', function() {
|
||||
if ($(this).val() == new_service_pcm_once_for_booking) {
|
||||
$('#new_service_pcm_days_container').hide();
|
||||
} else {
|
||||
$('#new_service_pcm_days_container').show();
|
||||
}
|
||||
});
|
||||
|
||||
// Add new custom service: change auto added option
|
||||
$(document).on('change', '#add_new_room_services_form input[name="new_service_auto_added"]', function() {
|
||||
var room_type_tax_rule_group_exist = $("#room_type_tax_rule_group_exist").val();
|
||||
|
||||
Reference in New Issue
Block a user