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

Commit adea224

Browse files
Merge pull request #7 from borlum/dev
Referencing issue #9928 of PrestaShop/PrestaShop
2 parents 8268c01 + 04e40e5 commit adea224

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
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

0 commit comments

Comments
 (0)