Updated the functions names

This commit is contained in:
vishalsingh.qlo325
2025-05-19 17:45:43 +05:30
parent df5eead3dd
commit 3ffa3b5adc
3 changed files with 24 additions and 18 deletions

View File

@@ -98,7 +98,7 @@ class CustomerGuestDetailCore extends ObjectModel
*
* @return bool True on success, false on failure
*/
public function deleteCartCustomerGuestByIdGuest()
public function deleteCustomerGuestFromCart()
{
return Db::getInstance()->delete(
'cart_customer_guest',
@@ -108,28 +108,34 @@ class CustomerGuestDetailCore extends ObjectModel
public function delete()
{
$this->deleteCartCustomerGuestByIdGuest();
$this->deleteCustomerGuestFromCart();
return parent::delete();
}
/**
* Deletes the guest profiles created by customer.
* Deletes the guest profiles created by a customer.
*
* @param int id_customer
* @param int offset
* @param int $idCustomer Customer ID
* @param int $offset Number of guests to skip
* @return bool True on success, false on failure
*/
public function deleteCustomerGuestByIdCustomer($idCustomer, $offset = 0)
{
$guests = $this->getCustomerGuestsByIdCustomer((int)$idCustomer);
if (empty($guests)) {
return true;
}
$guestsToDelete = array_slice($guests, $offset);
if (empty($guestsToDelete)) {
return true;
}
$res = true;
if (($guests = $this->getCustomerGuestsByIdCustomer($idCustomer))
&& ($guests = array_slice($guests, $offset))
) {
foreach ($guests as $guest) {
$objCustomerGuestDetail = new CustomerGuestDetail((int) $guest['id_customer_guest_detail']);
$res &= $objCustomerGuestDetail->delete();
}
foreach ($guestsToDelete as $guest) {
$customerGuestDetail = new CustomerGuestDetail($guest['id_customer_guest_detail']);
$res &= $customerGuestDetail->delete();
}
return $res;
@@ -175,7 +181,7 @@ class CustomerGuestDetailCore extends ObjectModel
* @param int id_customer_guest_detail
* @return array customer guest details.
*/
public static function getCustomerGuestDetail($idCustomerGuestDetail)
public static function getCustomerGuestDetailById($idCustomerGuestDetail)
{
return Db::getInstance()->getRow('
SELECT `id_gender`, `firstname`, `lastname`, `email`, `phone`
@@ -190,7 +196,7 @@ class CustomerGuestDetailCore extends ObjectModel
* @param int email
* @return int|false id customer guest details.
*/
public static function getIdCustomerGuest($email, $idCustomer = null, $idCart = 0)
public static function getCustomerGuestByEmail($email, $idCustomer = null, $idCart = 0)
{
return Db::getInstance()->getValue(
'SELECT cgd.`id_customer_guest_detail` FROM `'._DB_PREFIX_.'customer_guest_detail` as cgd

View File

@@ -1042,7 +1042,7 @@ class AdminCustomersControllerCore extends AdminController
$this->errors[] = Tools::displayError('Some error ocurred while deleting the Customer');
return;
} else {
if ($idCustomerGuest = CustomerGuestDetail::getIdCustomerGuest($customerEmail, false)) {
if ($idCustomerGuest = CustomerGuestDetail::getCustomerGuestByEmail($customerEmail, false)) {
$objCustomerGuestDetail = new CustomerGuestDetail($idCustomerGuest);
$objCustomerGuestDetail->phone = preg_replace('/[0-9]/', '0', $objCustomer->phone);
$objCustomerGuestDetail->email = $objCustomer->email;

View File

@@ -549,7 +549,7 @@ class OrderOpcControllerCore extends ParentOrderController
if ($this->isLogged) {
if ($idCustomerGuestDetail = CustomerGuestDetail::getCustomerGuestIdByIdCart($this->context->cart->id)) {
$this->context->smarty->assign(
'customer_guest_detail', CustomerGuestDetail::getCustomerGuestDetail($idCustomerGuestDetail)
'customer_guest_detail', CustomerGuestDetail::getCustomerGuestDetailById($idCustomerGuestDetail)
);
}
$this->context->smarty->assign('id_customer_guest_detail', $idCustomerGuestDetail);
@@ -1098,9 +1098,9 @@ 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 ($idCustomerGuestDetail = CustomerGuestDetail::getIdCustomerGuest($customerGuestDetailEmail, $this->context->cart->id)) {
if ($idCustomerGuestDetail = CustomerGuestDetail::getCustomerGuestByEmail($customerGuestDetailEmail, $this->context->cart->id)) {
$objCustomerGuestDetail = new CustomerGuestDetail($idCustomerGuestDetail);
} else if ($idCustomerGuestDetail = CustomerGuestDetail::getIdCustomerGuest($customerGuestDetailEmail, $this->context->customer->id, null)) {
} else if ($idCustomerGuestDetail = CustomerGuestDetail::getCustomerGuestByEmail($customerGuestDetailEmail, $this->context->customer->id, null)) {
$objCustomerGuestDetail = new CustomerGuestDetail($idCustomerGuestDetail);
} else {
$objCustomerGuestDetail = new CustomerGuestDetail();