Jump to content
Radi

Adding validate by checkbox on One Page Checkout

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)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More