Jump to content

[SOLVED] Free VATNumber module FIXED for PS 1.7.0.0-1.7.2.4


Recommended Posts

Afer many hours fighting with my Prestashop i solved this problem.

I installed this free vatnumber module: https://github.com/PrestaShop/vatnumber

But you need change three files in Prestashop too if you want it to work (front, back and order pages). It's not a perfect solution, but it works

I attach this fixed files and module vatnumber.zip (v.2.0.0). Verified for PS 1.7.0.0. 1.7.1.2 and 1.7.2.4.

If you like it, give me thanks :)

// AddressController.php - Add this after line 68
include_once(_PS_MODULE_DIR_.'vatnumber/vatnumber.php');
$isAVatNumber = VatNumber::WebServiceCheck(Tools::getValue('vat_number'));
if (is_array($isAVatNumber) && count($isAVatNumber) > 0) {
	$this->errors[] = $this->trans('Please fix the error below.', array(), 'Shop.Notifications.Error');
	$this->should_redirect = false;
	$this->success = null;
}
// AdminAddressesController.php - Add this after line 378
include_once(_PS_MODULE_DIR_.'vatnumber/vatnumber.php');
$isAVatNumber = VatNumber::WebServiceCheck(Tools::getValue('vat_number'));
if (is_array($isAVatNumber) && count($isAVatNumber) > 0) {
	$this->errors[] = $this->trans('VAT number not found', array(), 'Admin.Notifications.Error');
}
// CheckoutAddressesStep.php - Add this after line 112
include_once(_PS_MODULE_DIR_.'vatnumber/vatnumber.php');
$isAVatNumber = VatNumber::WebServiceCheck(Tools::getValue('vat_number'));
if (is_array($isAVatNumber) && count($isAVatNumber) > 0) {
	$saved = false;
}
// vatnumber.php - I changed this url for fix too spanish vat numbers validation in line 159
//		$url = 'http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms='.urlencode($prefix).'&iso='.urlencode($prefix).'&vat='.urlencode($vat);
// Spanish VAT numbers fixed. Fix error message: 'VAT number validation service unavailable'
$url = 'http://ec.europa.eu/taxation_customs/vies/vatResponse.html?locale=EN&memberStateCode='.urlencode($prefix).'&number='.$vat.'&traderName=';

 

VATNumber_fix_PS_1.7.0.0_-_1.7.2.4.zip

vatnumber.zip

Edited by wifilogo
SOLVED (see edit history)
  • Like 4
  • Thanks 1
Link to comment
Share on other sites

  • 5 weeks later...

Hello Wifilogo

I am negatively Amazed, just as many others, about PS 1.7 missing this very important feature, it was very nice of you to propose this free solution, finally someone did it, thank you for the effort.

In your installation, does your mod work exactly as the it was working in prestashop 1.6?

In mine, PS 1.7.2.4, it does not.

I am not a coder and have no great skills into this matter, by the way I reviewed the changes proposed and seemed not wrong or dangerous to start with, so I tried i out.

Unfortunately does not work as expected, at least on the presta 1.7.2.4 I am deploying the mechanism for which the VAT ID field should appear only if the field Company is used does not work, the VAT field is always visible and does not become mandatory only if company field is used.

So if one does set it as mandatory in the addresses tab of the BO everyone have to write the VAT ID and that does not help as the form is used by privates as well as companies.

Logically if the VAT ID always appears and is set to be mandatory and does verify the VAT ID on the VIES website then is also not possible to have the field as hybrid, e.g. to ask to input the VAT ID or the Fiscal code or Identification number or other code used by privates in different countries, further more in some countries that is not expected and won't be understood by private potential clients.

So the old module for presta 1.6 was doing the work just as needed covering the cases of local private, local company, Eu private, EU company, extra EU private and company, the modification of this same module for prestashop 1.7 should do exactly the same thing at least.

Hope a fix is possible, it is really a big pity to see this platform mutilated of such basic fundamental features.

Thank you

Best regards

 

 

 

Link to comment
Share on other sites

En 12/12/2017 a las 4:08 PM, daxit_x dijo:

I am negatively Amazed, just as many others, about PS 1.7 missing this very important feature

Yes.

The 'problem' is because PS 1.7 isn't ready for VAT Number feature like PS 1.5 or PS 1.6. VAT number module works fine!

In my old PS 1.5.6.2 i have this javascript code in address.tpl

	$(document).ready(function() {
		$('#company').on('input',function(){
			vat_number();
		});
		vat_number();
		function vat_number()
		{
			if ($('#company').val() != '')
				$('#vat_number').show();
			else
				$('#vat_number').hide();
		}
	});

And this smarty code

			{if $field_name eq 'company'}
				<div class="text form-group">
					<label class="control-label col-sm-4" for="company">{l s='Company'}</label>
					<div class="col-sm-6">
						<input class="form-control" type="text" id="company" name="company" value="{if isset($smarty.post.company)}{$smarty.post.company}{else}{if isset($address->company)}{$address->company|escape:'html'}{/if}{/if}" />
					</div>
				</div>
			{/if}
			{if $field_name eq 'vat_number'}
				<div id="vat_area">
					<div id="vat_number">
						<div class="text form-group">
							<label class="control-label col-sm-4" for="vat_number">{l s='VAT number'}</label>
							<div class="col-sm-6">
								<input type="text" class="form-control text" name="vat_number" value="{if isset($smarty.post.vat_number)}{$smarty.post.vat_number}{else}{if isset($address->vat_number)}{$address->vat_number|escape:'html'}{/if}{/if}" />
							</div>
						</div>
					</div>
				</div>
			{/if}

But in PS 1.7 only

      {block name="address_form_fields"}
        <section class="form-fields">
          {block name='form_fields'}
            {foreach from=$formFields item="field"}
              {block name='form_field'}
                {form_field field=$field}
              {/block}
            {/foreach}
          {/block}
        </section>
      {/block}

You need a lot of code in PS 1.7 (javascript and smarty) in different files  to add this show/hide feature :(

Link to comment
Share on other sites

Hello

Thank you for the reply, appreciated.

I saw that works fine in the sense that does not causes errors, but also does not much of what was doing in presta 1.6 or 1.5

So far I see that the module in 1.7  does not validate the VAT ID with he VIES service, do not remove the taxes from the cart if the purchase is done with an EU country VAT ID different from the shop owner's country.

Does this module accomplish to this tasks in your installation?

I am using prestashop 1.7.2.4, clean and fresh just out of the box, those are the results I got.

Bye

Link to comment
Share on other sites

  • 2 weeks later...
En 17/12/2017 a las 3:51 AM, daxit_x dijo:

Hello

Thank you for the reply, appreciated.

I saw that works fine in the sense that does not causes errors, but also does not much of what was doing in presta 1.6 or 1.5

So far I see that the module in 1.7  does not validate the VAT ID with he VIES service, do not remove the taxes from the cart if the purchase is done with an EU country VAT ID different from the shop owner's country.

Does this module accomplish to this tasks in your installation?

I am using prestashop 1.7.2.4, clean and fresh just out of the box, those are the results I got.

Bye

No.

This module and this changes over PS 1.7.x.x works fine!

Validate VAT ID with VIES online service and remove taxes. If VAT ID isn't valid, you can't save thid ID in address. And if VAT Number field is empty in Address, don't remove taxes. It's simple.

Regards!

 

Link to comment
Share on other sites

  • 5 months later...
  • 1 month later...
  • 5 weeks later...
  • 1 month later...
  • 2 months later...
  • 3 weeks later...
  • 7 months later...
On 1/21/2019 at 4:18 PM, Sandromultimedia said:

Hi,

This issue is resolved when the nif field becomes mandatory in the addresses in the Customers> Addresses> Required Fields option. You may need to change the format and options for your country first.

 

screen-15.16.38[21.01.2019].png

The problem with this, is I don't want it to be mandatory.  DNI, i think is only for Spain.  Not charging VAT to VAT registered customers, is how trade within the EU works.  I'm shocked that prestashop has addressed this issue.

https://europa.eu/youreurope/business/taxation/vat/cross-border-vat/index_en.htm#withintheeusellgoodsanotherbusiness

 

Link to comment
Share on other sites

  • 11 months later...
  • 2 years later...

Hi everyone. 
Try my chance here. 
I'm on Prestashop 1.7.8.7, using free module VAT and have the same error: 

"VAT number validation service unavailable"

try a lot of things, nothing works.

and when my customers from Italy, Deutschland, Belgium ... have a VAT number, they don't paid taxes. It's works since years and suddenly last week, this doesn't work anymore. I thinks it's linked. 

Can someone find a solution? (Prestashop can help me... in exchange of 89€...). 
Thx

vat number.png

Link to comment
Share on other sites

21 hours ago, AromEssence said:

Hi everyone. 
Try my chance here. 
I'm on Prestashop 1.7.8.7, using free module VAT and have the same error: 

"VAT number validation service unavailable"

try a lot of things, nothing works.

and when my customers from Italy, Deutschland, Belgium ... have a VAT number, they don't paid taxes. It's works since years and suddenly last week, this doesn't work anymore. I thinks it's linked. 

Can someone find a solution? (Prestashop can help me... in exchange of 89€...). 
Thx

vat number.png

Hi,
What module are you using?
I have made a module for the this feature (here).

But in all honesty the official Vies database has quite some offline time every now and then.

Edited by Inform-All (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 2 months later...

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