fix service product update process from opc page
This commit is contained in:
@@ -63,19 +63,21 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
|
||||
$objRoomTypeServiceProductCartDetail->id_cart = $idCart;
|
||||
}
|
||||
|
||||
$updateQty = $quantity - $objRoomTypeServiceProductCartDetail->quantity;
|
||||
if ($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;
|
||||
|
||||
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;
|
||||
if ($objRoomTypeServiceProductCartDetail->save()) {
|
||||
$objCart = new Cart($idCart);
|
||||
return $objCart->updateQty((int)abs($updateQty), $idProduct, null, false, $way);
|
||||
}
|
||||
$way = $updateQty > 0 ? 'up' : 'down';
|
||||
$objRoomTypeServiceProductCartDetail->quantity = $quantity;
|
||||
if ($objRoomTypeServiceProductCartDetail->save()) {
|
||||
$objCart = new Cart($idCart);
|
||||
return $objCart->updateQty((int)abs($updateQty), $idProduct, null, false, $way);
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -509,8 +509,14 @@ $(document).ready(function()
|
||||
var newQuantity = parseInt(qtyfield.val()) + 1;
|
||||
if (qtyfield.data('max_quantity') && qtyfield.data('max_quantity') < newQuantity) {
|
||||
newQuantity = qtyfield.data('max_quantity');
|
||||
}
|
||||
qtyfield.val(newQuantity).trigger('focusout');
|
||||
if (qtyfield.val() != qtyfield.data('max_quantity')) {
|
||||
qtyfield.trigger('focusout');
|
||||
} else {
|
||||
showSuccessMessage(txtMaxQuantityAdded);
|
||||
}
|
||||
} else {
|
||||
qtyfield.val(newQuantity).trigger('focusout');
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '#rooms_extra_services .qty_down', function(e) {
|
||||
@@ -520,7 +526,10 @@ $(document).ready(function()
|
||||
if (!isNaN(currentVal) && currentVal > 1) {
|
||||
qtyfield.val(currentVal - 1).trigger('focusout');
|
||||
} else {
|
||||
qtyfield.val(1).trigger('focusout');
|
||||
qtyfield.val(1);
|
||||
if (currentVal != 1) {
|
||||
qtyfield.trigger('focusout');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -506,6 +506,7 @@
|
||||
{capture}<a class="button button-small btn btn-default" href="{$smarty.capture.addressUrlAdd}" title="{l s='Update' js=1}"><span>{l s='Update' js=1}<i class="icon-chevron-right right"></i></span></a>{/capture}
|
||||
{addJsDefL name=liUpdate}{$smarty.capture.default|@addcslashes:'\''}{/addJsDefL}
|
||||
{addJsDefL name=txtExtraDemandSucc}{l s='Updated Successfully' js=1}{/addJsDefL}
|
||||
{addJsDefL name=txtMaxQuantityAdded}{l s='Maximum quantity of service added' js=1}{/addJsDefL}
|
||||
{addJsDefL name=txtExtraDemandErr}{l s='Some error occurred while updating demands' js=1}{/addJsDefL}
|
||||
{/strip}
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user