AbanteCart Community

AbanteCart Development => Customization help => Topic started by: Riin on June 15, 2014, 08:57:46 AM

Title: how can I make company name required?
Post by: Riin on June 15, 2014, 08:57:46 AM
How can I make "Company" a required field, both in the registration page and the guest checkout step 1 page?
Title: Re: how can I make company name required?
Post by: abantecart on June 15, 2014, 09:16:49 AM
Hello.

See code changes instructions:

Edit file:
https://github.com/abantecart/abantecart-src/blob/master/public_html/storefront/controller/pages/account/create.php

line: 160

Code: [Select]
$this->data['form'][ 'company' ] = $form->getFieldHtml( array(
                                                                       'type' => 'input',
                                                               'name' => 'company',
                                                               'value' => $this->request->post['company'],
                                                               'required' => false ));

Change required to true

Now you need to add error validation and text in the model:
https://github.com/abantecart/abantecart-src/blob/master/public_html/storefront/model/account/customer.php

Look for function line 268 :
Code: [Select]
public function validateRegistrationData( $data ) {

Similar change guest checkout:
https://github.com/abantecart/abantecart-src/blob/master/public_html/storefront/controller/pages/checkout/guest_step_1.php

Title: Re: how can I make company name required?
Post by: Riin on June 15, 2014, 03:32:27 PM
The first change was easy. The second one I'm having trouble with. I added this:

if ((mb_strlen($data['company']) < 3) || (mb_strlen($data['company']) > 128)) {
         $error['company'] = $this->language->get('error_required');
      }

to customer.php (error_required is defined in language definitions), but when I try to create an account and leave the company name blank it doesn't give me an error. What am I missing?
Title: Re: how can I make company name required?
Post by: Riin on June 16, 2014, 06:43:31 PM
Anyone?
Title: Re: how can I make company name required?
Post by: Riin on June 18, 2014, 11:27:44 AM
The first change was easy. The second one I'm having trouble with. I added this:

if ((mb_strlen($data['company']) < 3) || (mb_strlen($data['company']) > 128)) {
         $error['company'] = $this->language->get('error_required');
      }

to customer.php (error_required is defined in language definitions), but when I try to create an account and leave the company name blank it doesn't give me an error. What am I missing?

I still need to resolve this. Can someone please help?