Skip to content
This repository was archived by the owner on Oct 20, 2023. It is now read-only.

Commit 99ead06

Browse files
Merge pull request #8 from PrestaShop/dev
Deploy v2.1.0 of vatnumber module
2 parents 8268c01 + 84a31fd commit 99ead06

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed

VATNumberTaxManager.php

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,37 @@ class VATNumberTaxManager implements TaxManagerInterface
2828
{
2929
public static function isAvailableForThisAddress(Address $address)
3030
{
31-
return (!empty($address->vat_number)
32-
&& $address->id_country != Configuration::get('VATNUMBER_COUNTRY')
33-
&& Configuration::get('VATNUMBER_MANAGEMENT')
31+
/*
32+
HOTFIX
33+
34+
For some reason, this check is called 6 times (?)
35+
36+
1 w. the real address
37+
2 w.o. the real address
38+
39+
1 w. the real address
40+
2 w.o. the real address
41+
42+
=> [1 0 0 1 0 0]
43+
44+
So we need to filter out the weird calls...
45+
46+
We do this by caching the correct calls between calls;
47+
by creating a static variable, which we save the address to,
48+
if it does not contain NULL in some of the other fields.
49+
*/
50+
51+
static $cached_address = NULL;
52+
53+
if ($address->id_customer != NULL) {
54+
$cached_address = $address;
55+
}
56+
57+
// Now, check on the cached address object
58+
return (!empty($cached_address->vat_number)
59+
&& !empty($cached_address->id_country)
60+
&& $cached_address->id_country != Configuration::get('VATNUMBER_COUNTRY')
61+
&& Configuration::get('VATNUMBER_MANAGEMENT')
3462
);
3563
}
3664

config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<module>
33
<name>vatnumber</name>
44
<displayName><![CDATA[European VAT number]]></displayName>
5-
<version><![CDATA[2.0.0]]></version>
5+
<version><![CDATA[2.1.0]]></version>
66
<description><![CDATA[Enables you to enter the intra-community VAT number when creating the address. You must fill in the company field to allow entering the VAT number.]]></description>
77
<author><![CDATA[PrestaShop]]></author>
88
<tab><![CDATA[billing_invoicing]]></tab>

vatnumber.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct()
3333
{
3434
$this->name = 'vatnumber';
3535
$this->tab = 'billing_invoicing';
36-
$this->version = '2.0.0';
36+
$this->version = '2.1.0';
3737
$this->author = 'PrestaShop';
3838
$this->need_instance = 0;
3939

0 commit comments

Comments
 (0)