Jump to content
wifilogo

[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

Share this post


Link to post
Share on other sites

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

 

 

 

Share this post


Link to post
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 :(

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
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!

 

Share this post


Link to post
Share on other sites

Thank you so much for your hard works.

Sorry one question: for classes/ceckout there is a file named "CheckoutAddressStep.php": maybe it named "CheckoutAddressesStep.php"?

Thank you

Share this post


Link to post
Share on other sites

Hello,

 

seems this solution no longer works in 1.7.4.2. Any help? Thank you.

 

J

Share this post


Link to post
Share on other sites
En 2/8/2018 a las 3:33 PM, krasny dijo:

Hello,

 

seems this solution no longer works in 1.7.4.2. Any help? Thank you.

 

J

 

Hi,

Same problem here... this solution is not working on 1.7.4.2 :(

 

Share this post


Link to post
Share on other sites
On 1.09.2018 at 11:31 AM, Antakarana said:

 

Hi,

Same problem here... this solution is not working on 1.7.4.2 :(

 

 

and the same...

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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

 

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.

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