Skip to content

Commit

Permalink
Merge pull request #772 from abhishek-webkul/gli-1474
Browse files Browse the repository at this point in the history
Fixed: Phone number can not be edited during guest checkout
  • Loading branch information
rohit053 authored Jan 8, 2024
2 parents 08f5f4c + 4debd49 commit 06942dd
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions controllers/front/OrderOpcController.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,31 @@ public function init()
$this->context->customer->newsletter = (int)Tools::isSubmit('newsletter');
$this->context->customer->optin = (int)Tools::isSubmit('optin');
$this->context->customer->is_guest = (Tools::isSubmit('is_new_customer') ? !Tools::getValue('is_new_customer', 1) : 0);

if ($idAddressDelivery = Tools::getValue('opc_id_address_delivery')) {
$objAddress = new Address($idAddressDelivery);
if (Validate::isLoadedObject($objAddress)) {
$phoneMobile = Tools::getValue('phone_mobile');

if (Configuration::get('PS_ONE_PHONE_AT_LEAST') && !$phoneMobile) {
$this->errors[] = Tools::displayError('Mobile phone number is a required field.', false);
}

if (!Validate::isPhoneNumber($phoneMobile)) {
$this->errors[] = Tools::displayError('Please enter a valid Mobile phone number.', false);
}

if (!count($this->errors)) {
$objAddress->phone_mobile = $phoneMobile;
$objAddress->firstname = $this->context->customer->firstname;
$objAddress->lastname = $this->context->customer->lastname;
if (!$objAddress->save()) {
$this->errors[] = Tools::displayError('Something went wrong while saving phone number. Please try again.', false);
}
}
}
}

$return = array(
'hasError' => !empty($this->errors),
'errors' => $this->errors,
Expand Down

0 comments on commit 06942dd

Please sign in to comment.