Jump to content

Forcing vat number to be uppercase


ikran

Recommended Posts

Good morning,
how is it possible to force the insertion in uppercase on the input form of the vat number?
If customers do not write in capital letters, the vat number is not recognized as valid by the module for validating the vat number through vies.

Link to comment
Share on other sites

For new customers who register and enter the vat number with lowercase letters.
I've already tried adding the text-transform statement to the css: uppercase;
doing so, however, I see the text maiscolo only on screen, but it is stored in lowercase in the db.
So I would like to understand how to make sure that the vat number is stored in all letters.
I would like to try to use javascript like this:

<input type = "text" onkeyup = "this.value = this.value.toUpperCase ();">


but I don't know the path of the file that I have to modify ...

Link to comment
Share on other sites

The best way is to use custom.js because the html is generate by php and need an override. 

Try this : 
 

$( function() {
  $('#field-vat_number').change(function() {
    var value = $('#field-vat_number').val();
    $('#field-vat_number').val(value.toUpperCase());
  });
});


 

Link to comment
Share on other sites

Depends on your PS version, but I've just tried this on PS 1.7.80 and it works with by creating an override for the Address class.

<?php
class Address extends AddressCore
{
  public function __construct($id_address = null, $id_lang = null){
    parent::__construct($id_address, $id_lang);
    if($this->vat_number && ($this->vat_number != strtoupper($this->vat_number))){
        $this->vat_number = strtoupper($this->vat_number);
        $this->update();
    }
  }
}

I threw in the update() in case your module works by retrieving the vat_number column through the database rather than by using the Address class.

 

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

Il y a 4 heures, Knowband Plugins a dit :

Kindly add the below code in /themes/classic/theme.js

Bad idea, we never touch this file, strictly never, since it is the result of the compilation of the original files before the theme is put into production.

As it was perfectly explained by @okom3pom on PrestaShop 1.7 we use the custom.js file and for the style the customl.css file.

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...