Taxes apply

  • Posts: 81851
  • Thank you received: 13138
  • MODERATOR
8 years 2 months ago #234987

Hi,

I don't understand what you mean.
Individuals don't have VAT numbers. I'm a European citizen and I don't have such number and I've never seen an individual with such a number. Only companies have a VAT number and when they do, they don't have to pay the VAT.
So I don't see what is the problem with that behavior.
How do you want the system to know if the VAT should apply or not if it can't base itself on either the company name nor the VAT number ?

Please Log in or Create an account to join the conversation.

  • Posts: 79
  • Thank you received: 3
8 years 2 months ago #235220

Hi Nicholas you are right. I'm spanish and I'm an individual too, but if you buy a physical good, and customer need an invoice, The "Agencia Tributaria" (spanish Tax Office) require us a customer valid document number (included European customers). Indeed, I don't have a VAT number but I have a DNI/NIF, that for Spanish Tax Office, it works like VAT number for this purpose.

This is the fact because I need to modify this behaviour.

Anyway, our site only allow checkout to registered users, and we have a custom field that user fill in at registration. All what I need is to access to this custom field at getTaxType() function in "currency" class, because I tried whith next code but doesn't work.

$usr_joomla = JFactory::getUser();
$ursclass = hikashop_get('class.user');
$usr_hika = $usrclass->get($usr_joomla->id,'cms'); 

If I insert a var_dump($usr_hika); instruction I obtain NULL value
I am in checkout process and I am logged in with a valid user.

Regards

Last edit: 8 years 2 months ago by pljuarez.

Please Log in or Create an account to join the conversation.

  • Posts: 81851
  • Thank you received: 13138
  • MODERATOR
8 years 2 months ago #235223

Hi,

So what you want is to create a new custom field so that customers can enter their DNI/NIF if they are individuals.
That's possible via the menu Display->Custom fields.
But that doesn't change anything for the taxes calculation since the European individuals will have to pay the VAT whether they have/provide that number or not. We don't ask for such number on our end since there is no such requirement in France, but we still charge VAT to all European individuals purchasing something on our website.

In that getTaxType function, the custom address fields are available in the $address variable.
Your code is for loading the custom user fields. So it might explain why you don't get the value you want based on how you configured your custom field.

Last edit: 8 years 2 months ago by nicolas.

Please Log in or Create an account to join the conversation.

  • Posts: 79
  • Thank you received: 3
8 years 2 months ago #235331

Hi Nicholas, You don't understand me.

I have created in "users" table a custom field ("tipo_usuario"). This custom field stores user type (0= individuals, 1 Companies without VAT number, 2 = companies with VAT number) like I said in my previous post, this field is compulsory and user fill in when he register. The ONLY thing I need is change the "$taxType" variable returned by "getTaxType()" function placed in "currency" class, based on the value of my custom field "tipo_usuario" instead of the content of "address_vat" and "address_company" fields.

This is the reason I need access connected user id in order to access hikashop user data. Because, I'm overriding "currency" class code but when I try to get connected user data by JFactory::getUser(); function, I don't obtain anything.
Is there any other method to obtain hikashop user id ?

Regards

Last edit: 8 years 2 months ago by pljuarez.

Please Log in or Create an account to join the conversation.

  • Posts: 81851
  • Thank you received: 13138
  • MODERATOR
8 years 2 months ago #235345

Hi,

Then, I would recommend to do differently. You don't need to change the code to do what you want.
Just use the FTW user group plugin: extensions.joomla.org/extension/user-group-ftw-for-hikashop
With it, you'll be able to force the user group of the user after his registration based on a custom user field value.
Then, in your tax rules, instead of using the "customer type" to restrict the tax rules to one type of user, you can use the "access level" setting to restrict the tax rule to groups of users.
That way, you'll avoid having to hack HikaShop core files and no need to figure out why your code is not getting the user field value (it should from what I could see).

Please Log in or Create an account to join the conversation.

  • Posts: 79
  • Thank you received: 3
8 years 2 months ago #235610

Thanks Nicholas. We already discarded this solution some time ago because internal organization issues. Is for this because we are trying to override getTaxType()" function.

Any way, yesterday I found in php documentation why JFactory::getUser() returns NULL value. Again, like a great programming professor of mine said "Typicaly, the most simply solution, is the best solution"
I was using:
$usr_joomla = JFactory::getUser();
Instead of:
$usr_joomla =& JFactory::getUser();

:blush: Too simply and basical error.
For us, this issue has been solved.

Again. Thank you very much for your support

Last edit: 8 years 2 months ago by pljuarez.
The following user(s) said Thank You: nicolas

Please Log in or Create an account to join the conversation.

Time to create page: 0.060 seconds
Powered by Kunena Forum