This repository was archived by the owner on Oct 20, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +31
-3
lines changed Expand file tree Collapse file tree 1 file changed +31
-3
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments