From 3a178e955cd5591ef0be3cf65d402a4038956abf Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Mon, 3 Feb 2025 13:23:09 +0530 Subject: [PATCH 1/2] Added: new column phone in the customer table --- classes/Customer.php | 27 ++++----------------------- install/data/db_structure.sql | 1 + 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/classes/Customer.php b/classes/Customer.php index 2983aa607d..6923209a3c 100644 --- a/classes/Customer.php +++ b/classes/Customer.php @@ -149,8 +149,7 @@ class CustomerCore extends ObjectModel 'last_passwd_gen' => array('setter' => null), 'secure_key' => array('setter' => null), 'deleted' => array(), - 'passwd' => array('setter' => 'setWsPasswd'), - 'phone' => array() + 'passwd' => array('setter' => 'setWsPasswd') ), 'associations' => array( 'groups' => array('resource' => 'group'), @@ -180,6 +179,7 @@ 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,12 +206,8 @@ public function __construct($id = null) $this->id_default_group = (int)Configuration::get('PS_CUSTOMER_GROUP'); parent::__construct($id); - if ($this->email) { - $this->phone = CartCustomerGuestDetail::getCustomerPhone($this->email); - } - if (Configuration::get('PS_ONE_PHONE_AT_LEAST')) { - $this->webserviceParameters['fields']['phone']['required'] = true; + self::$definition['fields']['phone']['required'] = true; } } @@ -264,7 +260,7 @@ public function add($autodate = true, $null_values = true) } $success = parent::add($autodate, $null_values); $this->updateGroup($this->groupBox); - $this->updateCustomerAdditionalDetails(CartCustomerGuestDetail::getIdCustomerGuest($this->email)); + return $success; } @@ -289,22 +285,9 @@ public function update($nullValues = false) $objOldCustomer = new Customer($this->id); $success = parent::update(true); - $this->updateCustomerAdditionalDetails(CartCustomerGuestDetail::getIdCustomerGuest($objOldCustomer->email)); return $success; } - public function updateCustomerAdditionalDetails($idCustomerGuest) - { - $objCartCustomerGuestDetail = new CartCustomerGuestDetail($idCustomerGuest); - $objCartCustomerGuestDetail->id_cart = 0; - $objCartCustomerGuestDetail->id_gender = $this->id_gender; - $objCartCustomerGuestDetail->firstname = $this->firstname; - $objCartCustomerGuestDetail->lastname = $this->lastname; - $objCartCustomerGuestDetail->email = $this->email; - $objCartCustomerGuestDetail->phone = $this->phone; - return $objCartCustomerGuestDetail->save(); - } - public function delete() { if (!count(Order::getCustomerOrders((int)$this->id))) { @@ -343,8 +326,6 @@ public function delete() CartRule::deleteByIdCustomer((int)$this->id); // delete customer data from customerGuest table - $objCartCustomerGuestDetail = new CartCustomerGuestDetail(CartCustomerGuestDetail::getIdCustomerGuest($this->email)); - $objCartCustomerGuestDetail->delete(); return parent::delete(); } diff --git a/install/data/db_structure.sql b/install/data/db_structure.sql index de57c40246..c4dc5ff7e9 100644 --- a/install/data/db_structure.sql +++ b/install/data/db_structure.sql @@ -606,6 +606,7 @@ CREATE TABLE `PREFIX_customer` ( `max_payment_days` int(10) unsigned NOT NULL DEFAULT '60', `secure_key` varchar(32) NOT NULL DEFAULT '-1', `note` text, + `phone` varchar(32) DEFAULT NULL, `active` tinyint(1) unsigned NOT NULL DEFAULT '0', `is_guest` tinyint(1) NOT NULL DEFAULT '0', `deleted` tinyint(1) NOT NULL DEFAULT '0', From c8b970035f262d6be055f557137f6c130161ca19 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Mon, 17 Feb 2025 10:39:20 +0530 Subject: [PATCH 2/2] Added customer phone columm in the customer list --- controllers/admin/AdminCustomersController.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/controllers/admin/AdminCustomersController.php b/controllers/admin/AdminCustomersController.php index 38d0d82c9b..3a12667846 100644 --- a/controllers/admin/AdminCustomersController.php +++ b/controllers/admin/AdminCustomersController.php @@ -141,6 +141,11 @@ public function __construct() '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',