Merge 'origin/develop' into gli-838

This commit is contained in:
Shreesh Arora
2022-12-27 15:58:35 +05:30
604 changed files with 40717 additions and 14343 deletions

View File

@@ -135,6 +135,34 @@ class OrderOpcControllerCore extends ParentOrderController
$this->ajaxDie(json_encode($return));
break;
case 'transformGuestAccount':
$passwd = Tools::getValue('passwd');
if (!$passwd) {
$this->errors[] = Tools::displayError('Please enter a password.');
}
if ($passwd && !Validate::isPasswd($passwd)) {
$this->errors[] = Tools::displayError('Please enter a valid password.');
}
if (!count($this->errors)) {
$customer = new Customer($this->context->customer->id);
if ($customer->transformToCustomer($this->context->language->id, $passwd)) {
$this->updateContext($customer);
} else {
$this->errors[] = Tools::displayError('An error occurred while transforming your account into a registered customer.');
}
}
$return = array(
'hasError' => !empty($this->errors),
'errors' => $this->errors,
);
$this->ajaxDie(json_encode($return));
break;
case 'getAddressBlockAndCarriersAndPayments':
if ($this->context->customer->isLogged() || $this->context->customer->isGuest()) {
// check if customer have addresses
@@ -1021,4 +1049,20 @@ class OrderOpcControllerCore extends ParentOrderController
}
$this->context->cart->save();
}
public function updateContext(Customer $customer)
{
$this->context->cookie->id_customer = (int)$customer->id;
$this->context->cookie->customer_lastname = $customer->lastname;
$this->context->cookie->customer_firstname = $customer->firstname;
$this->context->cookie->passwd = $customer->passwd;
$this->context->cookie->logged = 1;
$this->context->cookie->email = $customer->email;
$this->context->cookie->is_guest = 0;
$this->context->cart->secure_key = $customer->secure_key;
$customer->logged = 1;
$this->context->customer = $customer;
}
}