Author Topic: how can I make company name required?  (Read 5367 times)

Offline Riin

  • Newbie
  • *
  • Posts: 43
  • Karma: +3/-0
    • View Profile
    • Happy Fuzzy Yarn (wholesale)
how can I make company name required?
« 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?
Riin Gill

Offline abantecart

  • Administrator
  • Hero Member
  • *****
  • Posts: 4358
  • Karma: +298/-10
    • View Profile
    • Ideal Open Source Ecommerce Solution
Re: how can I make company name required?
« Reply #1 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

Please  rate your experience or leave your review
We need your help to build better free open source ecommerce platform for everyone. See how you can help

Offline Riin

  • Newbie
  • *
  • Posts: 43
  • Karma: +3/-0
    • View Profile
    • Happy Fuzzy Yarn (wholesale)
Re: how can I make company name required?
« Reply #2 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?
Riin Gill

Offline Riin

  • Newbie
  • *
  • Posts: 43
  • Karma: +3/-0
    • View Profile
    • Happy Fuzzy Yarn (wholesale)
Re: how can I make company name required?
« Reply #3 on: June 16, 2014, 06:43:31 PM »
Anyone?
Riin Gill

Offline Riin

  • Newbie
  • *
  • Posts: 43
  • Karma: +3/-0
    • View Profile
    • Happy Fuzzy Yarn (wholesale)
Re: how can I make company name required?
« Reply #4 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?
Riin Gill

 

Powered by SMFPacks Social Login Mod