Skip to content

Commit 839622d

Browse files
authored
Merge pull request #579 from shreesh-webkul/gli-1265
Resolved: Exception on admin book now page after cleaning cart data
2 parents c107bbd + e4115ed commit 839622d

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php

+25-17
Original file line numberDiff line numberDiff line change
@@ -40,27 +40,15 @@ public function initCart()
4040
}
4141

4242
if (!isset($this->context->cookie->id_cart)) {
43-
// create a new cart
44-
$objCart = new Cart();
45-
$objCart->recyclable = 0;
46-
$objCart->gift = 0;
47-
$objCart->id_shop = (int) $this->context->shop->id;
48-
$objCart->id_lang = (($id_lang = (int) Tools::getValue('id_lang')) ? $id_lang : (int) Configuration::get('PS_LANG_DEFAULT'));
49-
$objCart->id_currency = (($id_currency = (int) Tools::getValue('id_currency')) ? $id_currency : (int) Configuration::get('PS_CURRENCY_DEFAULT'));
50-
$objCart->id_address_delivery = 0;
51-
$objCart->id_address_invoice = 0;
52-
$objCart->id_currency = (int) Configuration::get('PS_CURRENCY_DEFAULT');
53-
$objCart->id_guest = (int) $this->context->cookie->id_guest;
54-
$objCart->setNoMultishipping();
55-
56-
$this->context->cart = $objCart;
57-
$this->context->cart->save();
58-
43+
$objCart = $this->createNewCart();
5944
$this->context->cookie->id_cart = (int) $objCart->id;
6045
} else {
6146
// use previous cart
62-
$this->context->cart = new Cart($this->context->cookie->id_cart);
47+
if (!validate::isLoadedObject($objCart = new Cart($this->context->cookie->id_cart))) {
48+
$objCart = $this->createNewCart();
49+
}
6350
}
51+
$this->context->cart = $objCart;
6452

6553
$objCustomer = new Customer();
6654
$objCustomer->id_gender = 0;
@@ -77,6 +65,26 @@ public function initCart()
7765
$this->context->customer = $objCustomer;
7866
}
7967

68+
protected function createNewCart()
69+
{
70+
// create a new cart
71+
$objCart = new Cart();
72+
$objCart->recyclable = 0;
73+
$objCart->gift = 0;
74+
$objCart->id_shop = (int) $this->context->shop->id;
75+
$objCart->id_lang = (($id_lang = (int) Tools::getValue('id_lang')) ? $id_lang : (int) Configuration::get('PS_LANG_DEFAULT'));
76+
$objCart->id_currency = (($id_currency = (int) Tools::getValue('id_currency')) ? $id_currency : (int) Configuration::get('PS_CURRENCY_DEFAULT'));
77+
$objCart->id_address_delivery = 0;
78+
$objCart->id_address_invoice = 0;
79+
$objCart->id_currency = (int) Configuration::get('PS_CURRENCY_DEFAULT');
80+
$objCart->id_guest = (int) $this->context->cookie->id_guest;
81+
$objCart->setNoMultishipping();
82+
83+
$objCart->save();
84+
return $objCart;
85+
}
86+
87+
8088
public function postProcess()
8189
{
8290
if (Tools::getValue('date_from')) {

0 commit comments

Comments
 (0)