Page 1 of 2

require company field in checkout 1.5.1.3

Posted: Fri Feb 10, 2012 11:42 pm
by sferris
Hi. I have a customer that needs the company field to be required during checkout. Has anyone done this?

Re: require company field in checkout 1.5.1.3

Posted: Tue Feb 14, 2012 10:28 pm
by sferris
Really? No one knows how to make a field required in checkout?

Re: require company field in checkout 1.5.1.3

Posted: Tue Feb 14, 2012 11:18 pm
by madimar
Well, even if it can be simple, it can't be done without code modifications. You will need to work on both controller (adding field validation rules) and template files (mainly adding the asterisk *) for 3 sections: normal account registration, registration during checkout, checkout as guest.

regards,

M

Re: require company field in checkout 1.5.1.3

Posted: Tue Feb 14, 2012 11:40 pm
by jty
@madimar, why is your name blue
I know Q & D are red and the others are green but you're blue. Can I be pink

Re: require company field in checkout 1.5.1.3

Posted: Wed Feb 15, 2012 6:11 am
by dizarter
Because he is moderator. Q & D are admins :)

Re: require company field in checkout 1.5.1.3

Posted: Wed Feb 15, 2012 6:25 am
by madimar
jty wrote:@madimar, why is your name blue
I know Q & D are red and the others are green but you're blue. Can I be pink
Ahah, you could ask to Q to make you pink! :joker:

Re: require company field in checkout 1.5.1.3

Posted: Wed Feb 15, 2012 10:18 pm
by sferris
I already added the * to the fields in checkout, to at least make people think they are required. Which controller files would I need to look at? I can usually figure stuff out if I see an example, but nothing was jumping out at me when I looked.

Re: require company field in checkout 1.5.1.3

Posted: Thu Feb 16, 2012 1:53 am
by madimar
catalog/controller:
account/register.php
account/edit.php (if you want to avoid that a customer remove the company field content after registration)
checkout/register.php
checkout/guest.php

Ah, you will need also to slightly modify corresponding template files in order to show the error message in case of validation failure.

M

Re: require company field in checkout 1.5.1.3

Posted: Tue Mar 06, 2012 3:52 pm
by mediaindustries
Anyone got a detailed tutorial to fix this? I also need to add two extra fields to the address section and they need to be required (company number and tax number). If anyone can create an extension it would be nice, no problem to pay for it.

Re: require company field in checkout 1.5.1.3

Posted: Sun May 13, 2012 5:59 am
by nzplayer
Hi, I have written a vqmod for a mate of mine that makes the Company required.

http://www.web.nzplayer.com/index.php?r ... duct_id=95

R: require company field in checkout 1.5.1.3

Posted: Sun May 13, 2012 1:55 pm
by madimar
Have you seen my VAT number contribution?

M

Sent from my DesireHD.

Re: require company field in checkout 1.5.1.3

Posted: Sun May 13, 2012 2:12 pm
by Avvici
sferris wrote:I already added the * to the fields in checkout, to at least make people think they are required. Which controller files would I need to look at? I can usually figure stuff out if I see an example, but nothing was jumping out at me when I looked.
It's not that difficult. Let's walk you through it.

Open catalog/view/theme/default/template/account/register.tpl and find this line:

Code: Select all

<tr>
          <td><?php echo $entry_company; ?></td>
          <td><input type="text" name="company" value="<?php echo $company; ?>" /></td>
        </tr>
Make it look like this:

Code: Select all

 <tr>
          <td><span class="required">*</span> <?php echo $entry_company; ?></td>
          <td><input type="text" name="company" value="<?php echo $company; ?>" /><?php if ($error_company) { ?>
            <span class="error"><?php echo $error_company; ?></span>
            <?php } ?></td>
        </tr>
Now open catalog/controller/account/register.php and find this line:

Code: Select all

if (isset($this->error['zone'])) {
			$this->data['error_zone'] = $this->error['zone'];
		} else {
			$this->data['error_zone'] = '';
		}
Right below that add this:

Code: Select all

if (isset($this->error['company'])) {
			$this->data['error_company'] = $this->error['company'];
		} else {
			$this->data['error_company'] = '';
		}
Now find this line:

Code: Select all

if ($this->request->post['country_id'] == '') {
      		$this->error['country'] = $this->language->get('error_country');
    	}
Right below it add this:

Code: Select all

if ($this->request->post['company'] == '') {
      		$this->error['company'] = $this->language->get('error_company');
    	}
Lastly open language/english/account/register.php and add this to the list:

Code: Select all

$_['error_company']         = 'Warning: Company name required';
Done.

Re: require company field in checkout 1.5.1.3

Posted: Sat Aug 04, 2012 7:03 am
by enk
avvici, you are awesome! Thank you for that step-by-step procedure!

Re: require company field in checkout 1.5.1.3

Posted: Tue Oct 30, 2012 8:46 am
by RobiG
That was very helpful avvici. That worked great for making the Company field required during registration. How do I get this same result for the registration during the checkout process?

Re: require company field in checkout 1.5.1.3

Posted: Mon Nov 19, 2012 4:55 am
by mukur
Does anybody know the steps to do this in 1.5.4.1?

Re: require company field in checkout 1.5.1.3

Posted: Thu Jan 24, 2013 4:58 am
by Sparki
Hi,

Does someone know how to do this within the checkout form?
Just can't get it to work properly. Got it to do the verification ( I think, it will not continue without a company filled in) but no error message is generated.

Can someone help?

Regards,

Martijn

Re: require company field in checkout 1.5.1.3

Posted: Fri Aug 30, 2013 12:11 pm
by reason8
Thanks avvici -arvixe- I have made it onto a vQmod if anyone requires it and it works for OC 1.5.5.1 see attached.

Re: require company field in checkout 1.5.1.3

Posted: Sat Sep 14, 2013 7:18 pm
by Nawid
reason8 wrote:Thanks avvici -arvixe- I have made it onto a vQmod if anyone requires it and it works for OC 1.5.5.1 see attached.
Thank you for the files, It also works for OC 1.5.6
Question, How do you let this work in the checkout page, I mean like the page where people can place their order without login --> Direct Order page.

I believe it's something with checkout/checkout.php ?

Best regards,
Nawid

Re: require company field in checkout 1.5.1.3

Posted: Mon Sep 16, 2013 11:14 pm
by kelemvor
This works great from the Manual Create Account page but there are different files if they create an account from the Checkout process. Those files used are:
check/register.tpl
catalog/controller/checkout/register.php
catalog/language/english/checkout/register.php

I'm having trouble with the middle file since the format of that file doesn't match the format of the controller/account/register.php file.

Can anyone help with that file? or is there a way to disable creating an account from in the checkout process to force everyone to have to use the regular account creation page?

Thanks.

Re: require company field in checkout 1.5.1.3

Posted: Wed Sep 25, 2013 11:08 pm
by kelemvor
Has anyone else figured out how to do this for the Checkout pages?