- Posts: 79
- Thank you received: 3
Invalid VAT number for individuals, what can I do?
-- Joomla version -- : 3.2.3
-- PHP version -- : 5.3.3
Hello, I have select "online Vat number check" in Configuration->Taxes->VAT number check, and when I edit a "Company" Address with a Valid Company vat number works correctly, but when I edit a "Individual" address with a valid document number, I obtain an "Invalid VAT number" error.
I need this information for booth, individuals and Companies
Should I configure VAT number field in a special manner?
Regards
Please Log in or Create an account to join the conversation.
The VAT number field is only to be used for VAT numbers, not any other number.
If you need to collect a document number for individuals, them you should create a new custom field of the table "address" via the menu Display>Custom fields so that individuals could use that field instead of the VAT number field.
Please Log in or Create an account to join the conversation.
If answer is yes, where is it located? and how I can use it?
Or maybe:
Can I do this field required only for a group of users? because if I can do that, my problem wil be solved. Because I can change my users policy in order to assign a user type at the registration phase.
Regards
Please Log in or Create an account to join the conversation.
To check the VAT format on another custom field, you can create a plugin based on the function "onBeforeAddressCreate()" and "onBeforeAddressUpdate()". Then use the same functions as in the VAT helper in order to do the checks.
Something like:
Please Log in or Create an account to join the conversation.
Any way, I'm spanish, and while I am revising your code, I FOUND A BUG. I saw a VAT exception for Las Palmas (you use comment line "//skip VAT number check for las palmas as las palmas is not in the european VAT zone" before the code I saw). If you do this exception, you must also do it for Santa Cruz de Tenerife because the VAT exception is for all the autonomous community of the Canary Islands consists of two provinces Las Palmas and Santa Cruz de Tenerife (zone_code_3=='TF')
Regards
Please Log in or Create an account to join the conversation.
I have created and instaled my plugin named verifica_vat. (No installation errors). I think next step is use it.
I located address class at /administrator/components/com_hikashop/classes folder and I found save function on it that call _checkVat function and this one use vat helper.
I have 2 questions:
1.- May I change this class code in order to force it to use my plugin instead of helper? How can I do it?
2.- If first awnser is No, What should I do to use my plugin in order to verify VAT number?.
Thanks in advance.
Regards
Please Log in or Create an account to join the conversation.
Thanks for your report about the Santa Cruz de Tenerife exception.
Regarding the question about how to use the functions in the plugin instead of the one in the Helper, you have to use $this.
For example:
So if in the code you see something like:
Please Log in or Create an account to join the conversation.
should I do these changes at /administrator/components/com_hikashop/classes/address.php?
Regards
Please Log in or Create an account to join the conversation.
No, Xavier was talking about creating a new joomla plugin implementing specific code to handle that.
It's definitely not an easy task. You might need to hire a Joomla developer to help you with that if you're not familiar with such development. We have partners you can contact for such project here: www.hikashop.com/home/our-partners.html
But if you're a skilled PHP developer it shouldn't be a problem.
Please Log in or Create an account to join the conversation.
I had create my own plugin, I instaled it without errors, and I published it.
When I select HikaShop -> System ->Plugins->New. I can see it in the list (plugin-list.jpg). When I click on it, Joomla opens it in Joomla Plugin Manager (plugin_Manager.jpg). I saved it, and it appears enabled at Joomla Plugin Manager list (plugin_Man_list.jpg) but not at HickaShop System->plugin list.
The only thing I need to know is how can I invoke it? (I also attached php code and plugin xml.), because, I understood, when you install and publish a pluging, this plugin overrides every helper function you use into plugin.
Please, correct me if I'm wrong.
Regards
Please Log in or Create an account to join the conversation.
You need to deactivate the option "VAT number check" of the HikaShop configuration so that the VAT check is not done anymore by HikaShop.
Then, your plugin will be called automatically just before the address is saved and you'll be able to do the checks you want etc in your plugin.
I checked its code and it looks good. You should definitely get it called in the onBeforeAddressCreate function if you activated the plugin via the Joomla plugins manager.
Please Log in or Create an account to join the conversation.
I did some minors changes in my plugin php code replacing this code lines because hikashop vat_chek config is set to 0 :
by this other:
I have tried some scenarios putting some flags in the code, AND IT WORKS!!!
Regards
Please Log in or Create an account to join the conversation.
¿Have you modified vat_check behaviour?
Because, my plugin STOP WORK SUDENLY!!!. Some weeks ago it works but today I'm doing VAT tests and when I edit one of my Billing addresses at checkout it don't work.
No error messages, symply don't check VAT number anymore if i type "123456a" and clic "Ok button" Hikashop store this value without checking it
I insert in my plugin code one flag in order to see one value and don't work.
This is the flag;:
I look for my plugin in Joomla plugin manager and it is active, but in Hikashop Configuration->Plugins there are no plugins include if I create a new one, edit it and save it like Hikashop message said.
What can I do?
Please Log in or Create an account to join the conversation.
The onBeforeAddressCreate($addressData, $do) and onBeforeAddressUpdate($addressData, $do) triggers still work like before.
We didn't touch them in a long time.
So it must be something else.
Try on the backend of the website. The saving of the address in the backend should also trigger your plugin. If it doesn't, it means that the plugin is either not enabled, its files have been removed, or its access is restricted in some way.
If it works in the backend and not the frontend, then is a problem with the way your checkout is configured I suppose.
For example, maybe you changed the way the addresses are edited on the checkout with the settings of the Checkout tab of the HikaShop configuration.
Please Log in or Create an account to join the conversation.
My plugin does not work either in the backend. Maybe this can be influenced by the selections in System-> Configuration-> ACL? (I attach my "Plugins" ACL configuration)
Anyway, my plugin should be displayed in System->Plugins list?. Because there is no plugins also if I add new one via "New" button.
Thanks
Please Log in or Create an account to join the conversation.
No, you don't need to see it in System>Plugins.
But you need to enable it in the Joomla plugins manager.
Could you provide a copy of the plugin ? It would be easier to tell you what's wrong with it.
Please Log in or Create an account to join the conversation.
Attached are plugin files, which are the same as I attached a few posts above.
www.hikashop.com/forum/checkout/875355-i...can-i-do.html#193828
Files "verifica_vat.php" and "verifica_vat_xml.txt"
Anyway what's about ACL? , does ACL can affect?
Regards
Please Log in or Create an account to join the conversation.
The problem is indeed in your plugin.
The goal of the plugin is to change the $do variable passed to the onBeforeAddressCreate and onBeforeAddressUpdate functions to false when the vat number is invalid.
But to do that, you need to have the $do variable passed as a reference. And for that, you need to prefix the $do variable with the & symbol, like in our developer documentation:
www.hikashop.com/support/documentation/6...ntation.html#address
But you didn't put the & symbol in your plugin and thus, instead of having a reference to the $do variable, you get a copy of it. And thus, even if you change your copy to false, the original variable is still true and thus, even though your plugin is executed properly, it just doesn't do anything.
Add the & symbols and you'll see that it will work.
Please Log in or Create an account to join the conversation.
Like you said, the problem is in the plugin, because I have inserted a sleep(10) function behind a var_dump function in order to see the values of the user object, I tried with both objects in var_dump function ($usr_joomla and $usr_hika) and process waits 10 seconds (this means that the plugin is running) but I didn't obtain any output.
To obtain hikashop user id I used this code:
"user_tipo" is a custom field I created in user table.
Like you can see, I use JFactory::getUser() function in order to obtain a Joomla userid to obtain a valid hikashop userid and then I access to hikashop user custom fields values. Before last update this code ran correctly.
Did you modified hikashop user behaviour?
What can I do to access hikashop user custom fields values?
Thanks in advance
Please Log in or Create an account to join the conversation.
We didn't change anything. The custom user fields values are still in $usr_hika.
Please note however that this code won't work if you're not logged in.
For example, if you do a guest checkout: you still have a user address, but Joomla doesn't have a user account and thus $usr_joomla->id will be empty.
Also, doing a sleep won't help you debug your code.
A sleep will stop the processing of the request before resuming it. But what you echo in your code won't be sent to the browser until you do a flush or the process exit.
The simplest is to do it like that:
var_dump($usr_joomla);
exit;
That way, the process immediately stops and you get the var_dump data displayed.
Please Log in or Create an account to join the conversation.