remove disbale services from cart'

This commit is contained in:
Shreesh Arora
2023-03-07 11:58:37 +00:00
parent e81c0fbbee
commit 0f17dec89e
6 changed files with 31 additions and 0 deletions

View File

@@ -389,6 +389,9 @@ class OrderOpcControllerCore extends ParentOrderController
*/
public function initContent()
{
// check all service products are available
RoomTypeServiceProductCartDetail::validateServiceProductsInCart();
parent::initContent();
// check ORDER RESTRICT condition before payment by the customer

View File

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

View File

@@ -49,6 +49,9 @@ class BankwireValidationModuleFrontController extends ModuleFrontController
if (!$authorized)
die($this->module->l('This payment method is not available.', 'validation'));
// check all service products are available
RoomTypeServiceProductCartDetail::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,6 +50,9 @@ class ChequePaymentModuleFrontController extends ModuleFrontController
$total = $cart->getOrderTotal(true, Cart::BOTH);
}
// check all service products are available
RoomTypeServiceProductCartDetail::validateServiceProductsInCart();
$restrict_order = false;
/*Check Order restrict condition before Payment by the customer*/
if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) {

View File

@@ -48,6 +48,9 @@ class ChequeValidationModuleFrontController extends ModuleFrontController
if (!$authorized)
die($this->module->l('This payment method is not available.', 'validation'));
// check all service products are available
RoomTypeServiceProductCartDetail::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

@@ -341,4 +341,20 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
}
return false;
}
public static function validateServiceProductsInCart()
{
$context = Context::getContext();
if ($cartProducts = $context->cart->getProducts()) {
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
foreach ($cartProducts as $product) {
if (!$product['active'] && !$product['booking_product']) {
$serviceProducts = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart($context->cart->id, $product['id_product']);
foreach ($serviceProducts as $serviceProduct) {
$objRoomTypeServiceProductCartDetail->removeServiceProductByIdHtlCartBooking($serviceProduct['htl_cart_booking_id']);
}
}
}
}
}
}