diff --git a/modules/bankwire/controllers/front/payment.php b/modules/bankwire/controllers/front/payment.php index 4766877c8..8aa496109 100644 --- a/modules/bankwire/controllers/front/payment.php +++ b/modules/bankwire/controllers/front/payment.php @@ -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')) { diff --git a/modules/bankwire/controllers/front/validation.php b/modules/bankwire/controllers/front/validation.php index c6b818214..b7f70278f 100644 --- a/modules/bankwire/controllers/front/validation.php +++ b/modules/bankwire/controllers/front/validation.php @@ -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'; diff --git a/modules/cheque/controllers/front/payment.php b/modules/cheque/controllers/front/payment.php index 917a3bb06..2d92b7fdb 100644 --- a/modules/cheque/controllers/front/payment.php +++ b/modules/cheque/controllers/front/payment.php @@ -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')) { diff --git a/modules/cheque/controllers/front/validation.php b/modules/cheque/controllers/front/validation.php index af0fc080a..848dfa702 100644 --- a/modules/cheque/controllers/front/validation.php +++ b/modules/cheque/controllers/front/validation.php @@ -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'; diff --git a/modules/hotelreservationsystem/classes/HotelCartBookingData.php b/modules/hotelreservationsystem/classes/HotelCartBookingData.php index 6ad8d52eb..78822d985 100644 --- a/modules/hotelreservationsystem/classes/HotelCartBookingData.php +++ b/modules/hotelreservationsystem/classes/HotelCartBookingData.php @@ -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'); } } } diff --git a/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php b/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php index 06ec2cfe3..b89b9fb0f 100644 --- a/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php +++ b/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php @@ -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']); - } - } - } - } - } - } } diff --git a/modules/qloduitkupayment/controllers/front/validate.php b/modules/qloduitkupayment/controllers/front/validate.php index f2ce8100c..15dcbf8cf 100644 --- a/modules/qloduitkupayment/controllers/front/validate.php +++ b/modules/qloduitkupayment/controllers/front/validate.php @@ -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'])) { diff --git a/modules/qloduitkupayment/qloduitkupayment.php b/modules/qloduitkupayment/qloduitkupayment.php index 24d29b85c..e53ca05e1 100644 --- a/modules/qloduitkupayment/qloduitkupayment.php +++ b/modules/qloduitkupayment/qloduitkupayment.php @@ -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('
', array_unique($errors)), + ); + } $cartTotalAmount = $cart->is_advance_payment ? $cart->getOrderTotal(true, Cart::ADVANCE_PAYMENT)