Fixed: review changes

This commit is contained in:
amit sharma
2026-10-13 11:39:15 +05:30
parent c23e1dc9f1
commit d4c76bedd1
8 changed files with 13 additions and 56 deletions

View File

@@ -50,9 +50,6 @@ class BankwirePaymentModuleFrontController extends ModuleFrontController
$total = $cart->getOrderTotal(true, Cart::BOTH);
}
// check all service products are available
ServiceProductCartDetail::validateServiceProductsInCart();
$restrict_order = false;
/*Check Order restrict condition before Payment by the customer*/
if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) {

View File

@@ -49,9 +49,6 @@ class BankwireValidationModuleFrontController extends ModuleFrontController
if (!$authorized)
die($this->module->l('This payment method is not available.', 'validation'));
// check all service products are available
ServiceProductCartDetail::validateServiceProductsInCart();
// Check Order restrict condition before Payment by the customer
if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) {
require_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php';

View File

@@ -50,9 +50,6 @@ class ChequePaymentModuleFrontController extends ModuleFrontController
$total = $cart->getOrderTotal(true, Cart::BOTH);
}
// check all service products are available
ServiceProductCartDetail::validateServiceProductsInCart();
$restrict_order = false;
/*Check Order restrict condition before Payment by the customer*/
if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) {

View File

@@ -48,9 +48,6 @@ class ChequeValidationModuleFrontController extends ModuleFrontController
if (!$authorized)
die($this->module->l('This payment method is not available.', 'validation'));
// check all service products are available
ServiceProductCartDetail::validateServiceProductsInCart();
/*Check Order restrict condition before Payment by the customer*/
if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) {
require_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php';

View File

@@ -997,6 +997,9 @@ class HotelCartBookingData extends ObjectModel
// Without hotel/booking context, service must be sellable standalone.
if (!$isSellableAsStandalone) {
$toRemoveService = 1;
}else if($context->customer->id && !Customer::getAddressesTotalById((int) $context->customer->id)) {
// customer has no address, so we cannot sell standalone service product to them
$errors[] = $objModule->l('Please add an address to your account before proceeding with the order.', 'HotelOrderRestrictDate');
}
}
}

View File

@@ -662,46 +662,4 @@ class ServiceProductCartDetail extends ObjectModel
return parent::delete();
}
public static function validateServiceProductsInCart()
{
$context = Context::getContext();
$objServiceProductCartDetail = new ServiceProductCartDetail();
// standalone products require customer address before payment
if ($context->customer->id
&& !Customer::getAddressesTotalById((int) $context->customer->id)
&& count($objServiceProductCartDetail->getServiceProductsInCart(
$context->cart->id,
[
Product::SELLING_PREFERENCE_WITH_STANDALONE,
Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE,
Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE,
Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE,
],
0,
0
))
) {
Tools::redirect('index.php?controller=address&back='.urlencode('order.php?step=1'));
}
if ($cartProducts = $context->cart->getProducts()) {
foreach ($cartProducts as $product) {
if (!$product['active'] && !$product['booking_product']) {
if ($serviceProducts = $objServiceProductCartDetail->getServiceProductsInCart(
$context->cart->id,
[],
null,
null,
null,
$product['id_product']
)) {
foreach ($serviceProducts as $serviceProduct) {
$objServiceProductCartDetail->removeServiceProductByIdHtlCartBooking($serviceProduct['htl_cart_booking_id']);
}
}
}
}
}
}
}

View File

@@ -37,6 +37,9 @@ class QloDuitkuPaymentValidateModuleFrontController extends ModuleFrontControlle
if (isset($response['status']) && $response['status'] === true) {
$response['status'] = true;
} elseif (isset($response['message'])) {
$response['status'] = false;
$response['message'] = $response['message'];
} else if (isset($response['response']['statusMessage'])) {
$response['message'] = $response['response']['statusMessage'];
} elseif (isset($response['response']['title'])) {

View File

@@ -385,8 +385,13 @@ class QloDuitkuPayment extends PaymentModule
public function getDuitkuTransactionTokenResponse()
{
$cart = new Cart((int) $this->context->cart->id);
// Validate and remove non-selected services from the cart
ServiceProductCartDetail::validateServiceProductsInCart();
// Validate cart and remove invalid services from the cart
if ($errors = HotelCartBookingData::validateCartBookings()) {
return array(
'status' => false,
'message' => implode('<br>', array_unique($errors)),
);
}
$cartTotalAmount = $cart->is_advance_payment
? $cart->getOrderTotal(true, Cart::ADVANCE_PAYMENT)