From 8935b0a6703ab8b171e1ccaa911e03910a6fae8e Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Mon, 26 Dec 2022 14:41:07 +0530 Subject: [PATCH] created indivisual table of guest detail for cart and order --- .../controllers/orders/helpers/view/view.tpl | 113 ++++++++++++++++-- classes/Cart.php | 3 - ...Detail.php => CartCustomerGuestDetail.php} | 19 +-- classes/PaymentModule.php | 39 +++--- .../CheckoutCustomerDetailsStep.php | 4 +- classes/order/Order.php | 4 - classes/order/OrderCustomerGuestDetail.php | 74 ++++++++++++ controllers/admin/AdminOrdersController.php | 49 +++++++- controllers/front/OrderDetailController.php | 7 ++ controllers/front/OrderOpcController.php | 59 +++++---- install/data/db_structure.sql | 8 +- .../hotel-reservation-theme/order-detail.tpl | 37 ++++-- 12 files changed, 335 insertions(+), 81 deletions(-) rename classes/{CustomerGuestDetail.php => CartCustomerGuestDetail.php} (81%) create mode 100644 classes/order/OrderCustomerGuestDetail.php diff --git a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl index 3d9c89ec6..80fcb197a 100644 --- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -703,18 +703,66 @@
{$customer->ape}
{/if} --> - {if $order->id_customer_guest_detail} -
+ {if $customerGuestDetail} +
{l s='Guest'}
-
{l s='Name'}
-
{$customerGuestDetail->firstname} {$customerGuestDetail->lastname}

-
{l s='Email'}
-
{$customerGuestDetail->email}

-
{l s='Phone'}
-
{$customerGuestDetail->phone}
-
+
+
{l s='Name'}
+
{$customerGuestDetail->gender->name} {$customerGuestDetail->firstname} {$customerGuestDetail->lastname}
+
+
{l s='Email'}
+
{$customerGuestDetail->email}

+
{l s='Phone'}
+
{$customerGuestDetail->phone}
+
+ +
+
+ + {/if} {/if} @@ -1695,6 +1743,53 @@ /*END*/ + // for updating customer guest details + $('#edit_guest_details').on('click', function(e) { + e.preventDefault(); + $('#customer-guest-details-form').show(); + $('#customer-guest-details').hide(); + }); + + $('#cancle_edit_guest_details').on('click', function(e) { + e.preventDefault(); + $('#customer-guest-details-form').hide(); + $('#customer-guest-details').show(); + }); + + $('#submit_guest_details').on('click', function(e) { + e.preventDefault(); + $.ajax({ + type: 'POST', + headers: { + "cache-control": "no-cache" + }, + url: "{$link->getAdminLink('AdminOrders')|addslashes}", + dataType: 'JSON', + cache: false, + data: $('#customer-guest-details-form').serialize()+'&ajax=true&id_order='+id_order+'&action=updateGuestDetails', + success: function(result) { + if (result.success) { + if (result.msg) { + showSuccessMessage(result.msg); + } + if (result.data.guest_name) { + $('#customer-guest-details .guest_name').text(result.data.guest_name); + } + if (result.data.guest_email) { + $('#customer-guest-details .guest_email a').attr('href', 'mailto:'+result.data.guest_email).text(result.data.guest_email); + } + if (result.data.guest_phone) { + $('#customer-guest-details .guest_phone a').attr('href', 'tel'+result.data.guest_phone).text(result.data.guest_phone); + } + $('#customer-guest-details-form').hide(); + $('#customer-guest-details').show(); + } else if (result.errors) { + showErrorMessage(result.errors); + } + } + }); + }); + $(".textarea-autosize").autosize(); var date = new Date(); diff --git a/classes/Cart.php b/classes/Cart.php index 361942ff4..18b2c15cf 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -88,8 +88,6 @@ class CartCore extends ObjectModel */ public $is_advance_payment; - public $id_customer_guest_detail; - protected static $_nbProducts = array(); protected static $_isVirtualCart = array(); @@ -118,7 +116,6 @@ class CartCore extends ObjectModel 'id_currency' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_guest' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), - 'id_customer_guest_detail' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 'recyclable' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'gift' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), diff --git a/classes/CustomerGuestDetail.php b/classes/CartCustomerGuestDetail.php similarity index 81% rename from classes/CustomerGuestDetail.php rename to classes/CartCustomerGuestDetail.php index f78f8b231..d21c56c68 100644 --- a/classes/CustomerGuestDetail.php +++ b/classes/CartCustomerGuestDetail.php @@ -18,9 +18,10 @@ * @license https://store.webkul.com/license.html */ -class CustomerGuestDetailCore extends ObjectModel +class CartCustomerGuestDetailCore extends ObjectModel { public $id_customer_guest_detail; + public $id_cart; public $id_gender; public $firstname; public $lastname; @@ -30,10 +31,10 @@ class CustomerGuestDetailCore extends ObjectModel public $date_upd; public static $definition = array( - 'table' => 'customer_guest_detail', + 'table' => 'cart_customer_guest_detail', 'primary' => 'id_customer_guest_detail', 'fields' => array( - 'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_cart' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_gender' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'size' => 32), 'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'size' => 32), @@ -44,12 +45,12 @@ class CustomerGuestDetailCore extends ObjectModel ), ); - public static function getCustomerGuests($id_customer) + public static function getCartCustomerGuest($id_cart) { - return Db::getInstance()->getRow(' - SELECT `id_customer_guest_detail`, `id_gender`, `firstname`, `lastname`, `email`, `phone` - FROM `'._DB_PREFIX_.'customer_guest_detail` - WHERE `id_customer` = '.(int)$id_customer + return Db::getInstance()->getValue(' + SELECT `id_customer_guest_detail` + FROM `'._DB_PREFIX_.'cart_customer_guest_detail` + WHERE `id_cart` = '.(int)$id_cart ); } @@ -57,7 +58,7 @@ class CustomerGuestDetailCore extends ObjectModel { return Db::getInstance()->getRow(' SELECT `id_gender`, `firstname`, `lastname`, `email`, `phone` - FROM `'._DB_PREFIX_.'customer_guest_detail` + FROM `'._DB_PREFIX_.'cart_customer_guest_detail` WHERE `id_customer_guest_detail` = '.(int)$id_customer_guest_detail ); } diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index df6969c94..2a696c1ee 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -362,11 +362,6 @@ abstract class PaymentModuleCore extends Module $order->advance_paid_amount = (float)Tools::ps_round((float)$this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_); } - // save customer guest information - if ($this->context->cart->id_customer_guest_detail) { - $order->id_customer_guest_detail = (int)$this->context->cart->id_customer_guest_detail; - } - // Creating order $result = $order->add(); @@ -375,6 +370,22 @@ abstract class PaymentModuleCore extends Module throw new PrestaShopException('Can\'t save Order'); } + // save customer guest information + if ($id_customer_guest_detail = CartCustomerGuestDetail::getCartCustomerGuest($this->context->cart->id)) { + if (Validate::isLoadedObject($objCartCustomerGuestDetail = new CartCustomerGuestDetail( + $id_customer_guest_detail + ))) { + $objOrderCustomerGuestDetail = new OrderCustomerGuestDetail(); + $objOrderCustomerGuestDetail->id_gender = $objCartCustomerGuestDetail->id_gender; + $objOrderCustomerGuestDetail->firstname = $objCartCustomerGuestDetail->firstname; + $objOrderCustomerGuestDetail->lastname = $objCartCustomerGuestDetail->lastname; + $objOrderCustomerGuestDetail->email = $objCartCustomerGuestDetail->email; + $objOrderCustomerGuestDetail->phone = $objCartCustomerGuestDetail->phone; + $objOrderCustomerGuestDetail->id_order = (int)$order->id; + $objOrderCustomerGuestDetail->save(); + } + } + // Amount paid by customer is not the right one -> Status = payment error // We don't use the following condition to avoid the float precision issues : http://www.php.net/manual/en/language.types.float.php // if ($order->total_paid != $order->total_paid_real) @@ -1023,21 +1034,21 @@ abstract class PaymentModuleCore extends Module ); } // send mail to customer guest if customer booked for someone other. - if ($order->id_customer_guest_detail) { - if ($customerGuestDetail = CustomerGuestDetail::getCustomerGuestDetail( - $order->id_customer_guest_detail + if ($id_customer_guest_detail = OrderCustomerGuestDetail::isCustomerGuestBooking($order->id)) { + if ($objOrderCustomerGuestDetail = new OrderCustomerGuestDetail( + $id_customer_guest_detail )) { - if (Validate::isEmail($customerGuestDetail['email'])) { - $data['{firstname}'] = $customerGuestDetail['firstname']; - $data['{lastname}'] = $customerGuestDetail['lastname']; - $data['{email}'] = $customerGuestDetail['email']; + if (Validate::isEmail($objOrderCustomerGuestDetail->email)) { + $data['{firstname}'] = $objOrderCustomerGuestDetail->firstname; + $data['{lastname}'] = $objOrderCustomerGuestDetail->lastname; + $data['{email}'] = $objOrderCustomerGuestDetail->email; Mail::Send( (int)$order->id_lang, 'order_conf', Mail::l('Order confirmation', (int)$order->id_lang), $data, - $customerGuestDetail['email'], - $customerGuestDetail['firstname'].' '.$customerGuestDetail['lastname'], + $objOrderCustomerGuestDetail->email, + $objOrderCustomerGuestDetail->firstname.' '.$objOrderCustomerGuestDetail->lastname, null, null, $file_attachement, diff --git a/classes/checkoutProcess/CheckoutCustomerDetailsStep.php b/classes/checkoutProcess/CheckoutCustomerDetailsStep.php index 00d908283..7ec1fef59 100644 --- a/classes/checkoutProcess/CheckoutCustomerDetailsStep.php +++ b/classes/checkoutProcess/CheckoutCustomerDetailsStep.php @@ -43,9 +43,9 @@ class CheckoutCustomerDetailsStep extends AbstractCheckoutStep } } elseif (Tools::getValue('proceed_to_payment')) { $guestInfoComplete = true; - if ($this->context->cart->id_customer_guest_detail) { + if ($id_customer_guest_detail = CartCustomerGuestDetail::getCartCustomerGuest($this->context->cart->id)) { $guestInfoComplete = false; - $objCustomerGuestDetail = new CustomerGuestDetail($this->context->cart->id_customer_guest_detail); + $objCustomerGuestDetail = new CartCustomerGuestDetail($id_customer_guest_detail); if ($objCustomerGuestDetail->validateGuestInfo()) { $guestInfoComplete = true; } diff --git a/classes/order/Order.php b/classes/order/Order.php index 7bbbe06f2..548e58610 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -59,9 +59,6 @@ class OrderCore extends ObjectModel /** @var int Customer id */ public $id_customer; - /** @var int Customer guest id */ - public $id_customer_guest_detail; - /** @var int Carrier id */ public $id_carrier; @@ -209,7 +206,6 @@ class OrderCore extends ObjectModel 'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), - 'id_customer_guest_detail' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_carrier' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'current_state' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'secure_key' => array('type' => self::TYPE_STRING, 'validate' => 'isMd5'), diff --git a/classes/order/OrderCustomerGuestDetail.php b/classes/order/OrderCustomerGuestDetail.php new file mode 100644 index 000000000..9f7013bdd --- /dev/null +++ b/classes/order/OrderCustomerGuestDetail.php @@ -0,0 +1,74 @@ + +* @copyright 2010-2022 Webkul IN +* @license https://store.webkul.com/license.html +*/ + +class OrderCustomerGuestDetailCore extends ObjectModel +{ + public $id_order_customer_guest_detail; + public $id_order; + public $id_gender; + public $firstname; + public $lastname; + public $email; + public $phone; + public $date_add; + public $date_upd; + + public static $definition = array( + 'table' => 'order_customer_guest_detail', + 'primary' => 'id_order_customer_guest_detail', + 'fields' => array( + 'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_gender' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'size' => 32), + 'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'size' => 32), + 'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'size' => 128), + 'phone' => array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 32), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + ), + ); + + public static function isCustomerGuestBooking($id_order) + { + return Db::getInstance()->getValue(' + SELECT `id_order_customer_guest_detail` + FROM `'._DB_PREFIX_.'order_customer_guest_detail` + WHERE `id_order` = '.(int)$id_order + ); + } + + public function validateGuestInfo() + { + $isValid = true; + if (!trim($this->firstname) || !Validate::isName($this->firstname)) { + $isValid = false; + } + if (!trim($this->lastname) || !Validate::isName($this->lastname)) { + $isValid = false; + } + if (!trim($this->email) || !Validate::isEmail($this->email)) { + $isValid = false; + } + if (!trim($this->phone) || !Validate::isPhoneNumber($this->phone)) { + $isValid = false; + } + return $isValid; + } +} \ No newline at end of file diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index d500a73ee..08be801d0 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -1336,8 +1336,9 @@ class AdminOrdersControllerCore extends AdminController // get details if booking is done for some other guest $customerGuestDetail = false; - if ($order->id_customer_guest_detail) { - $customerGuestDetail = new CustomerGuestDetail($order->id_customer_guest_detail); + if ($id_customer_guest_detail = OrderCustomerGuestDetail::isCustomerGuestBooking($order->id)) { + $customerGuestDetail = new OrderCustomerGuestDetail($id_customer_guest_detail); + $customerGuestDetail->gender = new Gender($customerGuestDetail->id_gender, $this->context->language->id); } // gets warehouses to ship products, if and only if advanced stock management is activated @@ -1523,6 +1524,7 @@ class AdminOrdersControllerCore extends AdminController 'customer' => $customer, 'gender' => $gender, 'customerGuestDetail' => $customerGuestDetail, + 'genders' => Gender::getGenders(), 'customer_addresses' => $customer->getAddresses($this->context->language->id), 'addresses' => array( 'delivery' => $addressDelivery, @@ -1592,6 +1594,49 @@ class AdminOrdersControllerCore extends AdminController return parent::renderView(); } + public function ajaxProcessUpdateGuestDetails() + { + $response = array( + 'success' => false + ); + if (Validate::isLoadedObject($order = new Order(Tools::getValue('id_order')))) { + if ($id_customer_guest_detail = OrderCustomerGuestDetail::isCustomerGuestBooking($order->id)) { + if (Validate::isLoadedObject($objCustomerGuestDetail = new OrderCustomerGuestDetail($id_customer_guest_detail))) { + $id_gender = Tools::getValue('id_gender'); + $firstname = Tools::getValue('firstname'); + $lastname = Tools::getValue('lastname'); + $email = Tools::getValue('email'); + $phone = Tools::getValue('phone'); + $objCustomerGuestDetail->id_gender = $id_gender; + $objCustomerGuestDetail->firstname = $firstname; + $objCustomerGuestDetail->lastname = $lastname; + $objCustomerGuestDetail->email = $email; + $objCustomerGuestDetail->phone = $phone; + if ($objCustomerGuestDetail->validateGuestInfo()) { + if ($objCustomerGuestDetail->save()) { + $response['success'] = true; + $gender = new Gender($objCustomerGuestDetail->id_gender, $this->context->language->id); + $response['data']['guest_name'] = $gender->name.' '.$objCustomerGuestDetail->firstname.' '.$objCustomerGuestDetail->lastname ; + $response['data']['guest_email'] = $objCustomerGuestDetail->email; + $response['data']['guest_phone'] = $objCustomerGuestDetail->phone; + $response['msg'] = $this->l('Guest details are updated.'); + } else { + $response['errors'][] = $this->l('Unable to save guest details.'); + } + } else { + $response['errors'][] = $this->l('Invalid guest details, please check and try again.'); + } + } else { + $response['errors'][] = $this->l('Guest details not found.'); + } + } else { + $response['errors'][] = $this->l('Guest details not found.'); + } + } + + $this->ajaxDie(json_encode($response)); + } + public function ajaxProcessSearchProducts() { Context::getContext()->customer = new Customer((int)Tools::getValue('id_customer')); diff --git a/controllers/front/OrderDetailController.php b/controllers/front/OrderDetailController.php index 120a32022..07d84ff97 100644 --- a/controllers/front/OrderDetailController.php +++ b/controllers/front/OrderDetailController.php @@ -275,6 +275,12 @@ class OrderDetailControllerCore extends FrontController $customer = new Customer($order->id_customer); + $customerGuestDetail = false; + if ($id_customer_guest_detail = OrderCustomerGuestDetail::isCustomerGuestBooking($order->id)) { + $customerGuestDetail = new OrderCustomerGuestDetail($id_customer_guest_detail); + } + + //by webkul to show order details properly on order history page if (Module::isInstalled('hotelreservationsystem')) { @@ -457,6 +463,7 @@ class OrderDetailControllerCore extends FrontController 'shop_name' => strval(Configuration::get('PS_SHOP_NAME')), 'order' => $order, 'guestInformations' => (array)new Customer($order->id_customer), + 'customerGuestDetail' => $customerGuestDetail, 'currency' => new Currency($order->id_currency), 'order_state' => (int) $id_order_state, 'invoiceAllowed' => (int) Configuration::get('PS_INVOICE'), diff --git a/controllers/front/OrderOpcController.php b/controllers/front/OrderOpcController.php index 03d94e09d..2112ae0ba 100644 --- a/controllers/front/OrderOpcController.php +++ b/controllers/front/OrderOpcController.php @@ -483,10 +483,12 @@ class OrderOpcControllerCore extends ParentOrderController $this->_assignPayment(); // GUEST BOOKING if ($this->isLogged) { - if ($this->context->cart->id_customer_guest_detail) { - $this->context->smarty->assign('customer_guest_detail', CustomerGuestDetail::getCustomerGuestDetail($this->context->cart->id_customer_guest_detail)); + if ($id_customer_guest_detail = CartCustomerGuestDetail::getCartCustomerGuest($this->context->cart->id)) { + $this->context->smarty->assign( + 'customer_guest_detail', CartCustomerGuestDetail::getCustomerGuestDetail($id_customer_guest_detail) + ); } - $this->context->smarty->assign('id_customer_guest_detail', $this->context->cart->id_customer_guest_detail); + $this->context->smarty->assign('id_customer_guest_detail', $id_customer_guest_detail); } Tools::safePostVars(); @@ -978,31 +980,44 @@ class OrderOpcControllerCore extends ParentOrderController public function submitCustomerGuestDetail() { - $customer_guest_detail = Tools::getValue('customer_guest_detail'); + $customerGuestDetail = Tools::getValue('customer_guest_detail'); $this->context->cookie->__set('customer_details_proceeded', 0); $this->context->cookie->checkedTOS = false; - if ($customer_guest_detail) { - if ($this->context->cart->id_customer_guest_detail) { - $objCustomerGuestDetail = new CustomerGuestDetail($this->context->cart->id_customer_guest_detail); + if ($customerGuestDetail) { + if ($id_customer_guest_detail = CartCustomerGuestDetail::getCartCustomerGuest($this->context->cart->id)) { + $objCustomerGuestDetail = new CartCustomerGuestDetail($id_customer_guest_detail); } else { - $objCustomerGuestDetail = new CustomerGuestDetail(); + $objCustomerGuestDetail = new CartCustomerGuestDetail(); } - $customer_guest_detail_gender = Tools::getValue('customer_guest_detail_gender'); - $customer_guest_detail_firstname = Tools::getValue('customer_guest_detail_firstname'); - $customer_guest_detail_lastname = Tools::getValue('customer_guest_detail_lastname'); - $customer_guest_detail_email = Tools::getValue('customer_guest_detail_email'); - $customer_guest_detail_phone = Tools::getValue('customer_guest_detail_phone'); - $objCustomerGuestDetail->id_gender = $customer_guest_detail_gender; - $objCustomerGuestDetail->firstname = $customer_guest_detail_firstname; - $objCustomerGuestDetail->lastname = $customer_guest_detail_lastname; - $objCustomerGuestDetail->email = $customer_guest_detail_email; - $objCustomerGuestDetail->phone = $customer_guest_detail_phone; + + $customerGuestDetailGender = Tools::getValue('customer_guest_detail_gender'); + $customerGuestDetailFirstname = Tools::getValue('customer_guest_detail_firstname'); + $customerGuestDetailLastname = Tools::getValue('customer_guest_detail_lastname'); + $customerGuestDetailEmail = Tools::getValue('customer_guest_detail_email'); + $customerGuestDetailPhone = Tools::getValue('customer_guest_detail_phone'); + if (trim($customerGuestDetailGender) && Validate::isUnsignedInt($customerGuestDetailGender)) { + $objCustomerGuestDetail->id_gender = $customerGuestDetailGender; + } + if (trim($customerGuestDetailFirstname) && Validate::isName($customerGuestDetailFirstname)) { + $objCustomerGuestDetail->firstname = $customerGuestDetailFirstname; + } + if (trim($customerGuestDetailLastname) && Validate::isName($customerGuestDetailLastname)) { + $objCustomerGuestDetail->lastname = $customerGuestDetailLastname; + } + if (trim($customerGuestDetailEmail) && Validate::isEmail($customerGuestDetailEmail)) { + $objCustomerGuestDetail->email = $customerGuestDetailEmail; + } + if (trim($customerGuestDetailPhone) && Validate::isPhoneNumber($customerGuestDetailPhone)) { + $objCustomerGuestDetail->phone = $customerGuestDetailPhone; + } + $objCustomerGuestDetail->id_cart = $this->context->cart->id; $objCustomerGuestDetail->save(); - $this->context->cart->id_customer_guest_detail = $objCustomerGuestDetail->id; } else { - $objCustomerGuestDetail = new CustomerGuestDetail($this->context->cart->id_customer_guest_detail); - $objCustomerGuestDetail->delete(); - $this->context->cart->id_customer_guest_detail = false; + if ($id_customer_guest_detail = CartCustomerGuestDetail::getCartCustomerGuest($this->context->cart->id)) { + if (Validate::isLoadedObject($objCustomerGuestDetail = new CartCustomerGuestDetail($id_customer_guest_detail))) { + $objCustomerGuestDetail->delete(); + } + } } $this->context->cart->save(); } diff --git a/install/data/db_structure.sql b/install/data/db_structure.sql index 331237fe1..e6942a0bd 100644 --- a/install/data/db_structure.sql +++ b/install/data/db_structure.sql @@ -674,8 +674,8 @@ CREATE TABLE `PREFIX_customer_thread` ( ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 COLLATION; CREATE TABLE `PREFIX_order_customer_guest_detail` ( - `id_customer_guest_detail` int(10) unsigned NOT NULL auto_increment, - `id_cart` int(10) unsigned NOT NULL, + `id_order_customer_guest_detail` int(10) unsigned NOT NULL auto_increment, + `id_order` int(10) unsigned NOT NULL, `id_gender` int(10) unsigned NOT NULL, `firstname` varchar(32) NOT NULL, `lastname` varchar(32) NOT NULL, @@ -683,12 +683,12 @@ CREATE TABLE `PREFIX_order_customer_guest_detail` ( `phone` varchar(32) DEFAULT NULL, `date_add` datetime NOT NULL, `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_customer_guest_detail`) + PRIMARY KEY (`id_order_customer_guest_detail`) ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 COLLATION; CREATE TABLE `PREFIX_cart_customer_guest_detail` ( `id_customer_guest_detail` int(10) unsigned NOT NULL auto_increment, - `id_order` int(10) unsigned NOT NULL, + `id_cart` int(10) unsigned NOT NULL, `id_gender` int(10) unsigned NOT NULL, `firstname` varchar(32) NOT NULL, `lastname` varchar(32) NOT NULL, diff --git a/themes/hotel-reservation-theme/order-detail.tpl b/themes/hotel-reservation-theme/order-detail.tpl index bcfc6d8cd..3571a1205 100644 --- a/themes/hotel-reservation-theme/order-detail.tpl +++ b/themes/hotel-reservation-theme/order-detail.tpl @@ -93,23 +93,36 @@
    -
  • {l s='Customer Details'}

  • - {if isset($address_invoice->firstname) && $address_invoice->firstname} -
  • {l s='Name'}
    {$address_invoice->firstname|escape:'html':'UTF-8'} {$address_invoice->lastname|escape:'html':'UTF-8'}
  • - {/if} - {if isset($guestInformations['email']) && $guestInformations['email']} -
  • {l s='Email'}
    {$guestInformations['email']|escape:'html':'UTF-8'}
  • - {/if} - {if isset($address_invoice->phone_mobile) && $address_invoice->phone_mobile} -
  • {l s='Mobile Number'}
    {$address_invoice->phone_mobile|escape:'html':'UTF-8'}
  • - {/if} - {if isset($address_invoice->phone) && $address_invoice->phone} -
  • {l s='Phone Number'}
    {$address_invoice->phone|escape:'html':'UTF-8'}
  • +
  • {l s='Guest Details'}

  • + {if $customerGuestDetail} + {if isset($customerGuestDetail->firstname) && $customerGuestDetail->firstname} +
  • {l s='Name'}
    {$customerGuestDetail->firstname|escape:'html':'UTF-8'} {$customerGuestDetail->lastname|escape:'html':'UTF-8'}
  • + {/if} + {if isset($customerGuestDetail->email) && $customerGuestDetail->email} +
  • {l s='Email'}
    {$customerGuestDetail->email|escape:'html':'UTF-8'}
  • + {/if} + {if isset($customerGuestDetail->phone) && $customerGuestDetail->phone} +
  • {l s='Mobile Number'}
    {$customerGuestDetail->phone|escape:'html':'UTF-8'}
  • + {/if} + {else} + {if isset($address_invoice->firstname) && $address_invoice->firstname} +
  • {l s='Name'}
    {$address_invoice->firstname|escape:'html':'UTF-8'} {$address_invoice->lastname|escape:'html':'UTF-8'}
  • + {/if} + {if isset($guestInformations['email']) && $guestInformations['email']} +
  • {l s='Email'}
    {$guestInformations['email']|escape:'html':'UTF-8'}
  • + {/if} + {if isset($address_invoice->phone_mobile) && $address_invoice->phone_mobile} +
  • {l s='Mobile Number'}
    {$address_invoice->phone_mobile|escape:'html':'UTF-8'}
  • + {/if} + {if isset($address_invoice->phone) && $address_invoice->phone} +
  • {l s='Phone Number'}
    {$address_invoice->phone|escape:'html':'UTF-8'}
  • + {/if} {/if}
+ {$HOOK_ORDERDETAILDISPLAYED} {if !$is_guest}
{/if}