Monday 27 June 2011

Confirm Email Address in onepage checkout in magento


Add one tax box in billing.phtml (app/design/frontend/ yourtheme/ yourtheme/template/checkout/onepage/billing.phl)
Ex : After email address Texbox add this :

<label for="billing:confirm_email" class="required"><em>*</em><?php echo $this->__('Re-Type Email Address') ?></label>
            <div class="input-box">
<input type="text" name="billing[confirm_email]" id="billing:confirm_email" value="<?php  $conf=$this->htmlEscape($this->getAddress()->getEmail()); echo $conf; ?>" onchange="abc(this.value)" title="<?php echo $this->__('Re-Type Email Address') ?>" class="input-text validate-email required-entry"  />
             </div>
  Then go to the onepage.php(code/core/Mage/Checkout/Model/Type)
In onepage.php do the following  change in function:


protected function _processValidateCustomer(Mage_Sales_Model_Quote_Address $address)
foreach (array( 
                         'firstname'    => 'firstname',
                         'lastname'     => 'lastname',

                        'email'        => 'email',
                        'confirm_email' => 'confirm_email',
                        'password'     => 'customer_password',
                        'confirmation' => 'confirm_password',
                        'taxvat'       => 'taxvat',
                        'gender'       => 'gender', )

 In elseif(self::METHOD_GUEST == $this->getQuote()->getCheckoutMethod())

  $email = $address->getData('email');
  $c_email=$address->getData('confirm_email');
           
  if($c_email != $email)
  {
        return array(
                              'error'   => -1,
                              'message' => $this->_helper->__('Not match email address "%s"', $c_email)
                           );
   }
                       
   if (!Zend_Validate::is($email, 'EmailAddress'))
  {
       return array(
                            'error'   => -1,
                            'message' => $this->_helper->__('Invalid email address "%s"', $email)
                          );
   }

No comments:

Post a Comment