cancel
Showing results for 
Search instead for 
Did you mean: 

Mandatory field for address, telephone, pincode in shipping/billing process

SOLVED

Mandatory field for address, telephone, pincode in shipping/billing process

  1. Hi,

    How can I apply mandatory field for address, telephone, pincode in shipping/billing process for my customer in magento 2.2

     

    Thanks,

    Regards,

    Kalpanas

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Mandatory field for address, telephone, pincode in shipping/billing process

Hello @kalpanas,

 

If you plan to make the second field mandatory for the checkout, you should make it mandatory in the customer add/edit address form for consistency.

For the client side validation you need to edit each template that holds an address for and add required-entry class on the second row. Here are the templates I found for this:

  • customer/form/address.phtml
  • customer/address/edit.phtml
  • persistent/customer/form/register.phtml
  • customer/form/register.phtml
  • checkout/onepage/billing.phtml
  • checkout/onepage/shipping.phtml
  • paypal/express/review/address.phtml
  • persistent/checkout/onepage/billing.phtml

As for server side validation you need to copy the file

app/code/core/Mage/Customer/Model/Address.php to the local folder /app/code/local/Mage/Customer/Model/Address.php. You cannot extend this class because the class is never instantiated.
And you need to add something in the validate method.

After this section:

if (!Zend_Validate::is($this->getStreet(1), 'NotEmpty')) {
$errors[] = Mage::helper('customer')->__('Please enter the street.');
}


Add the validation for the second row

if (!Zend_Validate::is($this->getStreet(2), 'NotEmpty')) {
$errors[] = Mage::helper('customer')->__('Please enter the correct street.');
}

--
If my answer is useful, please Accept as Solution & give Kudos

View solution in original post

2 REPLIES 2

Re: Mandatory field for address, telephone, pincode in shipping/billing process

Hi @kalpanas

 

I understand the question you have asked !

 

if you want to make those fields mandatory , you will required to add required-entry css  class to those fields.

 

So here first you required to find the templates of those fields and add the required-entry class on the same .

 

Below i am sharing the link - which has similar problem and helps you to resolved your issue.

 

https://magento.stackexchange.com/questions/53063/how-to-make-the-second-address-field-required-duri...

 

 

Hope it helps !

if issue solved,Click Kudos & Accept as Solution

Re: Mandatory field for address, telephone, pincode in shipping/billing process

Hello @kalpanas,

 

If you plan to make the second field mandatory for the checkout, you should make it mandatory in the customer add/edit address form for consistency.

For the client side validation you need to edit each template that holds an address for and add required-entry class on the second row. Here are the templates I found for this:

  • customer/form/address.phtml
  • customer/address/edit.phtml
  • persistent/customer/form/register.phtml
  • customer/form/register.phtml
  • checkout/onepage/billing.phtml
  • checkout/onepage/shipping.phtml
  • paypal/express/review/address.phtml
  • persistent/checkout/onepage/billing.phtml

As for server side validation you need to copy the file

app/code/core/Mage/Customer/Model/Address.php to the local folder /app/code/local/Mage/Customer/Model/Address.php. You cannot extend this class because the class is never instantiated.
And you need to add something in the validate method.

After this section:

if (!Zend_Validate::is($this->getStreet(1), 'NotEmpty')) {
$errors[] = Mage::helper('customer')->__('Please enter the street.');
}


Add the validation for the second row

if (!Zend_Validate::is($this->getStreet(2), 'NotEmpty')) {
$errors[] = Mage::helper('customer')->__('Please enter the correct street.');
}

--
If my answer is useful, please Accept as Solution & give Kudos