diff --git a/admin/themes/default/template/controllers/customers/helpers/view/view.tpl b/admin/themes/default/template/controllers/customers/helpers/view/view.tpl
index 432be8ad9..467ea386e 100644
--- a/admin/themes/default/template/controllers/customers/helpers/view/view.tpl
+++ b/admin/themes/default/template/controllers/customers/helpers/view/view.tpl
@@ -688,8 +688,8 @@
{$customer_guest['firstname']} |
{$customer_guest['lastname']} |
{$customer_guest['phone']} |
- |
- |
+ |
+ |
{/foreach}
diff --git a/classes/Customer.php b/classes/Customer.php
index 2e8c3bba5..62abf08c1 100644
--- a/classes/Customer.php
+++ b/classes/Customer.php
@@ -149,7 +149,8 @@ class CustomerCore extends ObjectModel
'last_passwd_gen' => array('setter' => null),
'secure_key' => array('setter' => null),
'deleted' => array(),
- 'passwd' => array('setter' => 'setWsPasswd')
+ 'passwd' => array('setter' => 'setWsPasswd'),
+ 'phone' => array()
),
'associations' => array(
'groups' => array('resource' => 'group'),
@@ -179,7 +180,6 @@ class CustomerCore extends ObjectModel
'company' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),
'siret' => array('type' => self::TYPE_STRING, 'validate' => 'isSiret'),
'ape' => array('type' => self::TYPE_STRING, 'validate' => 'isApe'),
- 'phone' => array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 32),
'outstanding_allow_amount' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat', 'copy_post' => false),
'show_public_prices' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_post' => false),
'id_risk' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'copy_post' => false),
@@ -206,8 +206,12 @@ class CustomerCore extends ObjectModel
$this->id_default_group = (int)Configuration::get('PS_CUSTOMER_GROUP');
parent::__construct($id);
+ if ($this->email) {
+ $this->phone = CustomerGuestDetail::getCustomerPhone($this->email, false);
+ }
+
if (Configuration::get('PS_ONE_PHONE_AT_LEAST')) {
- self::$definition['fields']['phone']['required'] = true;
+ $this->webserviceParameters['fields']['phone']['required'] = true;
}
}
@@ -260,7 +264,7 @@ class CustomerCore extends ObjectModel
}
$success = parent::add($autodate, $null_values);
$this->updateGroup($this->groupBox);
-
+ $this->updateCustomerAdditionalDetails(CustomerGuestDetail::getIdCustomerGuest($this->email, false));
return $success;
}
@@ -285,9 +289,22 @@ class CustomerCore extends ObjectModel
$objOldCustomer = new Customer($this->id);
$success = parent::update(true);
+ $this->updateCustomerAdditionalDetails(CustomerGuestDetail::getIdCustomerGuest($objOldCustomer->email, false));
return $success;
}
+ public function updateCustomerAdditionalDetails($idCustomerGuest)
+ {
+ $objCustomerGuestDetail = new CustomerGuestDetail($idCustomerGuest);
+ $objCustomerGuestDetail->id_customer = 0;
+ $objCustomerGuestDetail->id_gender = $this->id_gender;
+ $objCustomerGuestDetail->firstname = $this->firstname;
+ $objCustomerGuestDetail->lastname = $this->lastname;
+ $objCustomerGuestDetail->email = $this->email;
+ $objCustomerGuestDetail->phone = $this->phone;
+ return $objCustomerGuestDetail->save();
+ }
+
public function delete()
{
if (!count(Order::getCustomerOrders((int)$this->id))) {
@@ -327,6 +344,11 @@ class CustomerCore extends ObjectModel
CartRule::deleteByIdCustomer((int)$this->id);
// delete customer data from customerGuest table
+ $objCustomerGuestDetail = new CustomerGuestDetail(CustomerGuestDetail::getIdCustomerGuest($this->email, false));
+ $objCustomerGuestDetail->delete();
+ $objCustomerGuestDetail = new CustomerGuestDetail();
+ $objCustomerGuestDetail->deleteCustomerGuestByIdCustomer($this->id);
+
return parent::delete();
}
diff --git a/classes/CustomerGuestDetail.php b/classes/CustomerGuestDetail.php
index 2bc07b422..84889e592 100644
--- a/classes/CustomerGuestDetail.php
+++ b/classes/CustomerGuestDetail.php
@@ -45,34 +45,64 @@ class CustomerGuestDetailCore extends ObjectModel
),
);
- public static function getCartCustomerGuest($id_cart)
+
+ /**
+ * Get the customer guest id by id cart.
+ *
+ * @param int id_cart
+ * @return int|false id_customer_guest_detail if exists
+ */
+ public static function getCustomerGuestIdByIdCart($id_cart)
{
return Db::getInstance()->getValue('
SELECT `id_customer_guest_detail`
FROM `'._DB_PREFIX_.'cart_customer_guest`
- WHERE `id_cart` = '.(int)$id_cart
+ WHERE `id_cart` = '.(int) $id_cart
);
}
- public static function saveCartCustomerGuest($idCart, $idCustomerGuestDetail)
+ /**
+ * set the customer guest id for the id cart.
+ *
+ * @param int id_cart
+ * @param int id_customer_guest_detail
+ * @return bool True on success, false on failure
+ */
+ public static function saveCustomerGuestInCart($idCart, $idCustomerGuestDetail)
{
- return Db::getInstance()->insert('cart_customer_guest', array(
- 'id_cart' => (int) $idCart,
- 'id_customer_guest_detail' => (int) $idCustomerGuestDetail
- ));
+ return Db::getInstance()->insert(
+ 'cart_customer_guest',
+ array(
+ 'id_cart' => (int) $idCart,
+ 'id_customer_guest_detail' => (int) $idCustomerGuestDetail
+ )
+ );
}
- public static function deleteCartCustomerGuest($idCart)
+ /**
+ * removes the customer guest id for the id cart.
+ *
+ * @param int id_cart
+ * @return bool True on success, false on failure
+ */
+ public static function deleteCustomerGuestInCart($idCart)
{
- return Db::getInstance()->delete('cart_customer_guest',
+ return Db::getInstance()->delete(
+ 'cart_customer_guest',
' `id_cart`='.(int) $idCart
);
}
+ /**
+ * Removes this guest's ID from all related cart entries.
+ *
+ * @return bool True on success, false on failure
+ */
public function deleteCartCustomerGuestByIdGuest()
{
- return Db::getInstance()->delete('cart_customer_guest',
- ' `id_customer_guest_detail`='.(int) $this->id
+ return Db::getInstance()->delete(
+ 'cart_customer_guest',
+ '`id_customer_guest_detail` = ' . (int) $this->id
);
}
@@ -83,42 +113,74 @@ class CustomerGuestDetailCore extends ObjectModel
return parent::delete();
}
+ /**
+ * Deletes the guest profiles created by customer.
+ *
+ * @param int id_customer
+ * @param int offset
+ * @return bool True on success, false on failure
+ */
public function deleteCustomerGuestByIdCustomer($idCustomer, $offset = 0)
{
$res = true;
- if ($guests = $this->getCustomerGuestsByIdCustomer($idCustomer, false, false, false, $offset)) {
+ if (($guests = $this->getCustomerGuestsByIdCustomer($idCustomer))
+ && ($guests = array_slice($guests, $offset))
+ ) {
foreach ($guests as $guest) {
$objCustomerGuestDetail = new CustomerGuestDetail((int) $guest['id_customer_guest_detail']);
- $objCustomerGuestDetail->delete();
+ $res &= $objCustomerGuestDetail->delete();
}
}
return $res;
}
- public function getCustomerGuestsByIdCustomer($idCustomer, $firstname = false, $lastname = false, $email = false, $offset = 0)
+ /**
+ * Retrieves guest profiles created by a customer using the "booking for someone else" feature.
+ *
+ * @param int $idCustomer The customer ID
+ * @param string $firstname Optional first name filter
+ * @param string $lastname Optional last name filter
+ * @param string $email Optional email filter
+ * @return array List of matching guest profiles
+ */
+ public function getCustomerGuestsByIdCustomer($idCustomer, $firstname = '', $lastname = '', $email = '')
{
- return Db::getInstance()->executeS('
- SELECT cgd.`id_customer_guest_detail`, cgd.`email`, cgd.`firstname`, cgd.`lastname`, cgd.`phone`
- FROM `'._DB_PREFIX_.'customer_guest_detail` cgd
- LEFT JOIN `'._DB_PREFIX_.'cart_customer_guest` ccg
- ON (ccg.`id_customer_guest_detail` = cgd.`id_customer_guest_detail`)
- WHERE cgd.`id_customer` = '.(int)$idCustomer.
- (($firstname !== false && $firstname != '') ? ' AND cgd.`firstname` LIKE "%'.$firstname.'%"' : ' ').
- (($lastname !== false && $lastname != '') ? ' AND cgd.`lastname` LIKE "%'.$lastname.'%"' : ' ').
- (($email !== false && $email != '') ? ' AND cgd.`email` LIKE "%'.$email.'%"' : ' ').
- 'GROUP BY cgd.`id_customer_guest_detail`'.
- ' Order BY date_add DESC '.
- (($offset) ? ' LIMIT 999999 OFFSET '.(int) $offset : ' ')
- );
+ $sql = 'SELECT cgd.`id_customer_guest_detail`, cgd.`email`, cgd.`firstname`, cgd.`lastname`, cgd.`phone`
+ FROM `' . _DB_PREFIX_ . 'customer_guest_detail` cgd
+ LEFT JOIN `' . _DB_PREFIX_ . 'cart_customer_guest` ccg
+ ON ccg.`id_customer_guest_detail` = cgd.`id_customer_guest_detail`
+ WHERE cgd.`id_customer` = '.(int) $idCustomer;
+
+ if ($firstname !== '') {
+ $sql .= ' AND cgd.`firstname` LIKE "%'.pSQL($firstname).'%"';
+ }
+
+ if ($lastname !== '') {
+ $sql .= ' AND cgd.`lastname` LIKE "%'.pSQL($lastname).'%"';
+ }
+
+ if ($email !== '') {
+ $sql .= ' AND cgd.`email` LIKE "%'.pSQL($email).'%"';
+ }
+
+ $sql .= ' GROUP BY cgd.`id_customer_guest_detail` ORDER BY cgd.`date_add` DESC';
+
+ return Db::getInstance()->executeS($sql);
}
- public static function getCustomerGuestDetail($id_customer_guest_detail)
+ /**
+ * Retrieves guest information using the Id.
+ *
+ * @param int id_customer_guest_detail
+ * @return array customer guest details.
+ */
+ public static function getCustomerGuestDetail($idCustomerGuestDetail)
{
return Db::getInstance()->getRow('
SELECT `id_gender`, `firstname`, `lastname`, `email`, `phone`
FROM `'._DB_PREFIX_.'customer_guest_detail`
- WHERE `id_customer_guest_detail` = '.(int)$id_customer_guest_detail
+ WHERE `id_customer_guest_detail` = '.(int) $idCustomerGuestDetail
);
}
diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php
index 187facb07..a02f50f0c 100644
--- a/classes/PaymentModule.php
+++ b/classes/PaymentModule.php
@@ -400,9 +400,9 @@ abstract class PaymentModuleCore extends Module
}
// save customer guest information
- if ($id_customer_guest_detail = CustomerGuestDetail::getCartCustomerGuest($this->context->cart->id)) {
+ if ($idCustomerGuestDetail = CustomerGuestDetail::getCustomerGuestIdByIdCart($this->context->cart->id)) {
if (Validate::isLoadedObject($objCustomerGuestDetail = new CustomerGuestDetail(
- $id_customer_guest_detail
+ $idCustomerGuestDetail
))) {
$objOrderCustomerGuestDetail = new OrderCustomerGuestDetail();
$objOrderCustomerGuestDetail->id_gender = $objCustomerGuestDetail->id_gender;
@@ -1229,9 +1229,9 @@ abstract class PaymentModuleCore extends Module
);
}
// send mail to customer guest if customer booked for someone other.
- if ($id_customer_guest_detail = OrderCustomerGuestDetail::isCustomerGuestBooking($order->id)) {
+ if ($idCustomerGuestDetail = OrderCustomerGuestDetail::isCustomerGuestBooking($order->id)) {
if ($objOrderCustomerGuestDetail = new OrderCustomerGuestDetail(
- $id_customer_guest_detail
+ $idCustomerGuestDetail
)) {
if (Validate::isEmail($objOrderCustomerGuestDetail->email)) {
$data['{firstname}'] = $objOrderCustomerGuestDetail->firstname;
@@ -1384,7 +1384,7 @@ abstract class PaymentModuleCore extends Module
} // End foreach $order_detail_list
// delete cart feature prices after booking creation success
- HotelRoomTypeFeaturePricing::deleteFeaturePrices($id_cart);
+ HotelRoomTypeFeaturePricing::deleteByIdCart($id_cart);
if (count($cart_rules)) {
foreach ($cart_rules as $idCartRule => $cartRule) {
diff --git a/classes/checkoutProcess/CheckoutCustomerDetailsStep.php b/classes/checkoutProcess/CheckoutCustomerDetailsStep.php
index a51cb3169..c75c4f5f6 100644
--- a/classes/checkoutProcess/CheckoutCustomerDetailsStep.php
+++ b/classes/checkoutProcess/CheckoutCustomerDetailsStep.php
@@ -39,9 +39,9 @@ class CheckoutCustomerDetailsStepCore extends AbstractCheckoutStepCore
}
} elseif (Tools::getValue('proceed_to_payment')) {
$guestInfoComplete = true;
- if ($id_customer_guest_detail = CustomerGuestDetail::getCartCustomerGuest($this->context->cart->id)) {
+ if ($idCustomerGuestDetail = CustomerGuestDetail::getCustomerGuestIdByIdCart($this->context->cart->id)) {
$guestInfoComplete = false;
- $objCustomerGuestDetail = new CustomerGuestDetail($id_customer_guest_detail);
+ $objCustomerGuestDetail = new CustomerGuestDetail($idCustomerGuestDetail);
if ($objCustomerGuestDetail->validateGuestInfo()) {
$guestInfoComplete = true;
}
diff --git a/controllers/admin/AdminCustomerPreferencesController.php b/controllers/admin/AdminCustomerPreferencesController.php
index 14d091f91..76bfa40d6 100644
--- a/controllers/admin/AdminCustomerPreferencesController.php
+++ b/controllers/admin/AdminCustomerPreferencesController.php
@@ -121,14 +121,15 @@ class AdminCustomerPreferencesControllerCore extends AdminController
'cast' => 'intval',
'type' => 'bool'
),
- 'PS_CUSTOMER_GUEST_MAX_NUM' => array(
- 'title' => $this->l('Maximum Customers guests'),
- 'hint' => $this->l('Maximum number of guests a customer can add using the "booking for someone else" feature. Set as 0 for no limit.'),
+ 'PS_CUSTOMER_GUEST_MAX_LIMIT' => array(
+ 'title' => $this->l('Maximum Guests per Customer'),
'validation' => 'isUnsignedInt',
'cast' => 'intval',
'size' => 5,
'type' => 'text',
'class' => 'fixed-width-xl',
+ 'hint' => $this->l('Enter the maximum number of guest profiles a customer can create when using the "Booking for Someone Else" option.'),
+ 'desc' => $this->l('Set as 0 for no limit.')
),
),
'submit' => array(
diff --git a/controllers/admin/AdminCustomersController.php b/controllers/admin/AdminCustomersController.php
index 3a0af4c64..6e83dd3bb 100644
--- a/controllers/admin/AdminCustomersController.php
+++ b/controllers/admin/AdminCustomersController.php
@@ -141,11 +141,6 @@ class AdminCustomersControllerCore extends AdminController
'align' => 'text-right',
'badge_success' => true
),
- 'phone' => array(
- 'title' => $this->l('Phone'),
- 'optional' => true,
- 'visible_default' => false,
- ),
'active' => array(
'title' => $this->l('Enabled'),
'align' => 'text-center',
@@ -1438,27 +1433,30 @@ class AdminCustomersControllerCore extends AdminController
// Check tab access is allowed to edit
if ($this->tabAccess['edit'] == 1) {
if (Validate::isLoadedObject($objCustomerGuestDetail = new CustomerGuestDetail((int) Tools::getValue('id_customer_guest_detail')))) {
- $objCustomerGuestDetail->id_gender = Tools::getValue('id_gender');
- $objCustomerGuestDetail->firstname = Tools::getValue('firstname');
- $objCustomerGuestDetail->lastname = Tools::getValue('lastname');
- $objCustomerGuestDetail->phone = Tools::getValue('phone');
- if ($objCustomerGuestDetail->save()) {
- $gender = new Gender($objCustomerGuestDetail->id_gender, $this->context->language->id);
- $response['data']['gender'] = $gender->name;
- $response['data']['firstname'] = $objCustomerGuestDetail->firstname;
- $response['data']['lastname'] = $objCustomerGuestDetail->lastname ;
- $response['data']['email'] = $objCustomerGuestDetail->email;
- $response['data']['phone'] = $objCustomerGuestDetail->phone;
- $response['data']['id'] = $objCustomerGuestDetail->id;
- $response['msg'] = $this->l('Guest details are updated.');
- } else {
- $response['errors'][] = $this->l('Unable to save guest details.');
+ $response['errors'] = $objCustomerGuestDetail->validateController();
+ if (!$response['errors']) {
+ $objCustomerGuestDetail->id_gender = Tools::getValue('id_gender');
+ $objCustomerGuestDetail->firstname = Tools::getValue('firstname');
+ $objCustomerGuestDetail->lastname = Tools::getValue('lastname');
+ $objCustomerGuestDetail->phone = Tools::getValue('phone');
+ if ($objCustomerGuestDetail->save()) {
+ $gender = new Gender($objCustomerGuestDetail->id_gender, $this->context->language->id);
+ $response['data']['gender'] = $gender->name;
+ $response['data']['firstname'] = $objCustomerGuestDetail->firstname;
+ $response['data']['lastname'] = $objCustomerGuestDetail->lastname ;
+ $response['data']['email'] = $objCustomerGuestDetail->email;
+ $response['data']['phone'] = $objCustomerGuestDetail->phone;
+ $response['data']['id'] = $objCustomerGuestDetail->id;
+ $response['msg'] = $this->l('Guest details are updated.');
+ } else {
+ $response['errors'][] = Tools::displayError('Unable to save guest details.');
+ }
}
} else {
- $response['errors'][] = $this->l('Guest details not found.');
+ $response['errors'][] = Tools::displayError('Guest details not found.');
}
} else {
- $response['errors'][] = $this->l('You do not have permission to edit this.');
+ $response['errors'][] = Tools::displayError('You do not have permission to edit this.');
}
if ($response['errors']) {
diff --git a/controllers/front/OrderOpcController.php b/controllers/front/OrderOpcController.php
index ac66b6486..f8b1642f3 100644
--- a/controllers/front/OrderOpcController.php
+++ b/controllers/front/OrderOpcController.php
@@ -556,12 +556,12 @@ class OrderOpcControllerCore extends ParentOrderController
$this->_assignPayment();
// GUEST BOOKING
if ($this->isLogged) {
- if ($id_customer_guest_detail = CustomerGuestDetail::getCartCustomerGuest($this->context->cart->id)) {
+ if ($idCustomerGuestDetail = CustomerGuestDetail::getCustomerGuestIdByIdCart($this->context->cart->id)) {
$this->context->smarty->assign(
- 'customer_guest_detail', CustomerGuestDetail::getCustomerGuestDetail($id_customer_guest_detail)
+ 'customer_guest_detail', CustomerGuestDetail::getCustomerGuestDetail($idCustomerGuestDetail)
);
}
- $this->context->smarty->assign('id_customer_guest_detail', $id_customer_guest_detail);
+ $this->context->smarty->assign('id_customer_guest_detail', $idCustomerGuestDetail);
}
Tools::safePostVars();
@@ -1085,10 +1085,10 @@ class OrderOpcControllerCore extends ParentOrderController
$this->context->cart->id_customer,
$firstname,
$lastname,
- $email,
+ $email
)) {
$response['status'] = true;
- $response['guestDetails'] = $guestDetails;
+ $response['guest_details'] = $guestDetails;
}
return json_encode($response);
@@ -1107,10 +1107,10 @@ class OrderOpcControllerCore extends ParentOrderController
$customerGuestDetailLastname = Tools::getValue('customer_guest_detail_lastname');
$customerGuestDetailEmail = Tools::getValue('customer_guest_detail_email');
$customerGuestDetailPhone = Tools::getValue('customer_guest_detail_phone');
- if ($id_customer_guest_detail = CustomerGuestDetail::getIdCustomerGuest($customerGuestDetailEmail, $this->context->cart->id)) {
- $objCustomerGuestDetail = new CustomerGuestDetail($id_customer_guest_detail);
- } else if ($id_customer_guest_detail = CustomerGuestDetail::getIdCustomerGuest($customerGuestDetailEmail, $this->context->customer->id, null)) {
- $objCustomerGuestDetail = new CustomerGuestDetail($id_customer_guest_detail);
+ if ($idCustomerGuestDetail = CustomerGuestDetail::getIdCustomerGuest($customerGuestDetailEmail, $this->context->cart->id)) {
+ $objCustomerGuestDetail = new CustomerGuestDetail($idCustomerGuestDetail);
+ } else if ($idCustomerGuestDetail = CustomerGuestDetail::getIdCustomerGuest($customerGuestDetailEmail, $this->context->customer->id, null)) {
+ $objCustomerGuestDetail = new CustomerGuestDetail($idCustomerGuestDetail);
} else {
$objCustomerGuestDetail = new CustomerGuestDetail();
}
@@ -1166,19 +1166,19 @@ class OrderOpcControllerCore extends ParentOrderController
$objCustomerGuestDetail->phone = $customerGuestDetailPhone;
$objCustomerGuestDetail->id_customer = $this->context->customer->id;
if ($objCustomerGuestDetail->save()) {
- if ($maxGuestAccountAllowed = Configuration::get('PS_CUSTOMER_GUEST_MAX_NUM')) {
+ if ($maxGuestAccountAllowed = Configuration::get('PS_CUSTOMER_GUEST_MAX_LIMIT')) {
$objCustomerGuestDetail->deleteCustomerGuestByIdCustomer($this->context->cart->id_customer, $maxGuestAccountAllowed);
}
// To prevent duplications for the same cart.
- CustomerGuestDetail::deleteCartCustomerGuest($this->context->cart->id);
- CustomerGuestDetail::saveCartCustomerGuest($this->context->cart->id, $objCustomerGuestDetail->id);
+ CustomerGuestDetail::deleteCustomerGuestInCart($this->context->cart->id);
+ CustomerGuestDetail::saveCustomerGuestInCart($this->context->cart->id, $objCustomerGuestDetail->id);
Tools::redirect($this->context->link->getPageLink('order-opc', null, $this->context->language->id, array('proceed_to_payment' => 1)));
}
}
$this->context->smarty->assign('customerGuestDetailErrors', $customerGuestDetailErrors);
} else {
- CustomerGuestDetail::deleteCartCustomerGuest($this->context->cart->id);
+ CustomerGuestDetail::deleteCustomerGuestInCart($this->context->cart->id);
Tools::redirect($this->context->link->getPageLink('order-opc', null, $this->context->language->id, array('proceed_to_payment' => 1)));
}
diff --git a/install/data/xml/configuration.xml b/install/data/xml/configuration.xml
index 23012b781..173ff0178 100644
--- a/install/data/xml/configuration.xml
+++ b/install/data/xml/configuration.xml
@@ -950,7 +950,7 @@
0
-
+
5
diff --git a/themes/hotel-reservation-theme/js/order-opc.js b/themes/hotel-reservation-theme/js/order-opc.js
index df3f26a0e..2db984950 100644
--- a/themes/hotel-reservation-theme/js/order-opc.js
+++ b/themes/hotel-reservation-theme/js/order-opc.js
@@ -187,17 +187,15 @@ $(document).ready(function()
setCustomerGuestDetailForm(guestDetail);
}
} else if (!((keyCode < 65 || keyCode > 122) && (keyCode < 48 || keyCode > 57) && (keyCode != 8))) {
- $('.customer_guest_detail_ul').remove();
clearTimeout(debounceTimeout); // Clear the existing timeout
debounceTimeout = setTimeout(() => {
let firstName = '';
let lastName = '';
let email = '';
- let target = false
if ($(e.target).prop('id') == 'customer_guest_detail_firstname') {
- firstName = $('#customer_guest_detail_firstname').val()
+ firstName = $('#customer_guest_detail_firstname').val();
} else if ($(e.target).prop('id') == 'customer_guest_detail_lastname') {
- lastName = $('#customer_guest_detail_lastname').val()
+ lastName = $('#customer_guest_detail_lastname').val();
} else if ($(e.target).prop('id') == 'customer_guest_detail_email') {
email = $('#customer_guest_detail_email').val();
}
@@ -219,11 +217,12 @@ $(document).ready(function()
email : email,
},
success: function(data) {
+ $('.customer_guest_detail_ul').remove();
if (data.status) {
let listElem = $('').addClass('customer_guest_detail_ul');
- $.each(data.guestDetails, function(index, guestDetail) {
- let itemElem = $('- ').addClass('customer_guest_detail_li').text(guestDetail.firstname + ' '+ guestDetail.lastname + ' ('+ guestDetail.email+')');
- $(itemElem).attr('data-guest_detail', JSON.stringify(guestDetail));
+ $.each(data.guest_details, function(index, guest_detail) {
+ let itemElem = $('
- ').addClass('customer_guest_detail_li').text(guest_detail.firstname + ' '+ guest_detail.lastname + ' ('+ guest_detail.email+')');
+ $(itemElem).attr('data-guest_detail', JSON.stringify(guest_detail));
$(listElem).append(itemElem);
});
if ($(targetElem).prop('id') == 'customer_guest_detail_email') {
@@ -233,6 +232,8 @@ $(document).ready(function()
}
}
});
+ } else {
+ $('.customer_guest_detail_ul').remove();
}
}, 200);
}