Jump to content

Adding validate by checkbox on One Page Checkout


Radi

Recommended Posts

I'm trying prepare my own validation

 

In authcontroller.php i made

if (Tools::getValue('firm') == "1"){

if (!Tools::getValue('vat_number'))

$this->errors[] = Tools::displayError('You have chosen that you want to get invoice, please fill in VAT ID');

if (!Tools::getValue('company'))

$this->errors[] = Tools::displayError('You have chosen that you want to get invoice, please fill in company name');

}

 

Add add to authentication.tpl

<p class="checkbox">

<input type="checkbox" name="firm" id="firm" value="1">

<label for="firm">{l s='I need an invoice'}</label>

</p>

 

All works fine ! If customer check checkbox "firm" run validation and it is what i need.

 

But in One Page Checkout i try do the same but use

 

<p class="checkbox">

<input type="checkbox" name="invoice_address" id="invoice_address" value="1"/>

<label for="invoice_address"><b>{l s='Please use another address for invoice'}</b></label>

</p>

 

 

if (Tools::getValue('invoice_address') == "1"){

if (!Tools::getValue('vat_number_invoice'))

$this->errors[] = Tools::displayError('You have chosen that you want to get invoice, please fill in VAT ID');

if (!Tools::getValue('company_invoice'))

$this->errors[] = Tools::displayError('You have chosen that you want to get invoice, please fill in company name');

}

 

 

 

 

I would like validate empty fields and show errors like previous example on authentication :

<input type="text" class="text" id="vat_number_invoice" name="vat_number_invoice" value="" />

and

<input type="text" class="text" id="company_invoice" name="company_invoice" value="" />

 

I'm look in forum and try made changes few days but no results :(

I'm begginer. Can anybody help how made changes?

Edited by Radi (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...