Merge branch 'origin/develop' into gli-1078
This commit is contained in:
@@ -121,6 +121,31 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
$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,
|
||||
@@ -221,10 +246,19 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
if (($id_order = $this->_checkFreeOrder()) && $id_order) {
|
||||
$order = new Order((int)$id_order);
|
||||
$email = $this->context->customer->email;
|
||||
$orderConfirmationUrl = $this->context->link->getPageLink('order-confirmation').'?id_cart='.$order->id_cart.'&id_module=-1'.'&id_order='.$id_order.'&key='.$order->secure_key;
|
||||
if ($this->context->customer->is_guest) {
|
||||
$this->context->customer->logout();
|
||||
} // If guest we clear the cookie for security reason
|
||||
$this->ajaxDie('freeorder:'.$order->reference.':'.$email);
|
||||
|
||||
$return = array(
|
||||
'success' => true,
|
||||
'reference' => $order->reference,
|
||||
'email' => $email,
|
||||
'order_confirmation_url' => $orderConfirmationUrl,
|
||||
);
|
||||
|
||||
$this->ajaxDie(json_encode($return));
|
||||
}
|
||||
exit;
|
||||
break;
|
||||
@@ -520,6 +554,7 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
Tools::safePostVars();
|
||||
|
||||
$newsletter = Configuration::get('PS_CUSTOMER_NWSL') || (Module::isInstalled('blocknewsletter') && Module::getInstanceByName('blocknewsletter')->active);
|
||||
$this->context->smarty->assign('birthday', (bool) Configuration::get('PS_CUSTOMER_BIRTHDATE'));
|
||||
$this->context->smarty->assign('newsletter', $newsletter);
|
||||
$this->context->smarty->assign('optin', (bool)Configuration::get('PS_CUSTOMER_OPTIN'));
|
||||
$this->context->smarty->assign('field_required', $this->context->customer->validateFieldsRequiredDatabase());
|
||||
|
||||
Reference in New Issue
Block a user