diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index cc9b3adfd..4b4cf141d 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -888,14 +888,6 @@ abstract class PaymentModuleCore extends Module // delete cart feature prices after booking creation success HotelRoomTypeFeaturePricing::deleteByIdCart($id_cart); - if (isset($_COOKIE['wk_id_cart'])) { - setcookie('wk_id_cart', ' ', time() - 86400, '/'); - setcookie('wk_id_guest', ' ', time() - 86400, '/'); - - unset($_COOKIE['wk_id_cart']); - unset($_COOKIE['wk_id_guest']); - } - if (self::DEBUG_MODE) { PrestaShopLogger::addLog('PaymentModule::validateOrder - Hook validateOrder is about to be called', 1, null, 'Cart', (int)$id_cart, true); } diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index c4b81f1e4..180e4d60c 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -869,13 +869,14 @@ class AdminOrdersControllerCore extends AdminController false, $cart->secure_key ); - /* - setcookie('wk_id_cart', ' ', time() - 86400, '/'); - setcookie('wk_id_guest', ' ', time() - 86400, '/'); - unset($_COOKIE['wk_id_cart']); - unset($_COOKIE['wk_id_guest']); - */ + if (isset($this->context->cookie->id_cart)) { + unset($this->context->cookie->id_cart); + } + if (isset($this->context->cookie->id_guest)) { + unset($this->context->cookie->id_guest); + } + if ($payment_module->currentOrder) { Tools::redirectAdmin(self::$currentIndex.'&id_order='.$payment_module->currentOrder.'&vieworder'.'&token='.$this->token.'&conf=3'); } diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index c5c34ae8d..ef6a2c7f6 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -975,8 +975,9 @@ class HotelBookingDetail extends ObjectModel */ public function getAvailableRoomsForReallocation($date_from, $date_to, $room_type, $hotel_id) { - if (isset($_COOKIE['wk_id_cart'])) { - $current_admin_cart_id = $_COOKIE['wk_id_cart']; + $context = Context::getContext(); + if (isset($context->cookie->id_cart)) { + $current_admin_cart_id = $context->cookie->id_cart; } $exclude_ids = 'SELECT `id_room` FROM `'._DB_PREFIX_.'htl_booking_detail` WHERE `date_from` < \''.pSQL($date_to).'\' AND `date_to` > \''.pSQL($date_from).'\' diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php index d60d06254..6f5f109d2 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php @@ -30,65 +30,51 @@ class AdminHotelRoomsBookingController extends ModuleAdminController parent::__construct(); - $this->setPhpCookieData(); + $this->initCart(); } - public function setPhpCookieData() + public function initCart() { - if (!isset($_COOKIE['wk_id_guest']) || !$_COOKIE['wk_id_guest']) { - if (!isset($this->context->cookie->id_guest)) { - Guest::setNewGuest($this->context->cookie); - } - - setcookie('wk_id_guest', $this->context->cookie->id_guest, time() + 86400, "/"); - } else { - $this->context->cookie->id_guest = $_COOKIE['wk_id_guest']; - setcookie('wk_id_guest', $this->context->cookie->id_guest, time() + 86400, "/"); - } - $guest = new Guest($this->context->cookie->id_guest); - - if (!isset($_COOKIE['wk_id_cart']) && !isset($this->context->cart->id)) { - $cart = new Cart(); - - $cart->recyclable = 0; - $cart->gift = 0; - $cart->id_shop = (int)$this->context->shop->id; - $cart->id_lang = (($id_lang = (int)Tools::getValue('id_lang')) ? $id_lang : Configuration::get('PS_LANG_DEFAULT')); - $cart->id_currency = (($id_currency = (int)Tools::getValue('id_currency')) ? $id_currency : Configuration::get('PS_CURRENCY_DEFAULT')); - $cart->id_address_delivery = 0; - $cart->id_address_invoice = 0; - $cart->id_currency = Configuration::get('PS_CURRENCY_DEFAULT'); - $cart->id_guest = (int)$this->context->cookie->id_guest; - $cart->setNoMultishipping(); - $cart->save(); - - $this->context->cart = $cart; - $this->context->cookie->id_cart = $cart->id; - - setcookie('wk_id_cart', $cart->id, time() + 86400, "/"); - } else { - $cart = new Cart((int)$_COOKIE['wk_id_cart']); - - $this->context->cart = $cart; - $this->context->cookie->id_cart = $cart->id; - setcookie('wk_id_cart', $cart->id, time() + 86400, "/"); + if (!isset($this->context->cookie->id_guest)) { + Guest::setNewGuest($this->context->cookie); } - $customer = new Customer(); - $customer->id_gender = 0; - $customer->id_default_group = 1; - $customer->outstanding_allow_amount = 0; - $customer->show_public_prices = 0; - $customer->max_payment_days = 0; - $customer->active = 1; - $customer->is_guest = 0; - $customer->deleted = 0; - $customer->logged = 0; - $customer->id_guest = $this->context->cookie->id_guest; + if (!isset($this->context->cookie->id_cart)) { + // create a new cart + $objCart = new Cart(); + $objCart->recyclable = 0; + $objCart->gift = 0; + $objCart->id_shop = (int) $this->context->shop->id; + $objCart->id_lang = (($id_lang = (int) Tools::getValue('id_lang')) ? $id_lang : (int) Configuration::get('PS_LANG_DEFAULT')); + $objCart->id_currency = (($id_currency = (int) Tools::getValue('id_currency')) ? $id_currency : (int) Configuration::get('PS_CURRENCY_DEFAULT')); + $objCart->id_address_delivery = 0; + $objCart->id_address_invoice = 0; + $objCart->id_currency = (int) Configuration::get('PS_CURRENCY_DEFAULT'); + $objCart->id_guest = (int) $this->context->cookie->id_guest; + $objCart->setNoMultishipping(); - $this->context->customer = $customer; + $this->context->cart = $objCart; + $this->context->cart->save(); - return true; + $this->context->cookie->id_cart = (int) $objCart->id; + } else { + // use previous cart + $this->context->cart = new Cart($this->context->cookie->id_cart); + } + + $objCustomer = new Customer(); + $objCustomer->id_gender = 0; + $objCustomer->id_default_group = 1; + $objCustomer->outstanding_allow_amount = 0; + $objCustomer->show_public_prices = 0; + $objCustomer->max_payment_days = 0; + $objCustomer->active = 1; + $objCustomer->is_guest = 0; + $objCustomer->deleted = 0; + $objCustomer->logged = 0; + $objCustomer->id_guest = (int) $this->context->cookie->id_guest; + + $this->context->customer = $objCustomer; } public function postProcess()