lat9 / vat4eu

VAT Processing for European Countries for Zen Cart 1.5.8a and 2.0.x
Other
1 stars 2 forks source link

wrong VAT4EU_APPROVAL_PENDING message for normal customers #21

Closed webchills closed 8 months ago

webchills commented 2 years ago

ZC157d PHP 8

Login with a "normal" customer without UID Every customer without VAT ID gets the message Once your VAT Number () has been validated, your qualifying orders will automatically receive a VAT Exemption via message stack permanently.

This is wrong and coming from

includes/classes/observers/auto.vat_for_eu_countries.php line 103 - 109 if (zen_is_logged_in() && !zen_in_guest_checkout()) { $address_id = (isset($_SESSION['billto'])) ? $_SESSION['billto'] : $_SESSION['customer_default_address_id']; $this->getVatNumber($_SESSION['customer_id'], $address_id); if ($this->vatNumber !== '' && $this->vatNumberStatus !== VatValidation::VAT_ADMIN_OVERRIDE && $this->vatNumberStatus !== VatValidation::VAT_VIES_OK) { $messageStack->add('header', sprintf(VAT4EU_APPROVAL_PENDING, $this->vatNumber), 'warning'); } }

lat9 commented 2 years ago

Thanks, @webchills. I've got some personal issues that I'm dealing with, so it might be a while until I circle back to these.

webchills commented 2 years ago

Take time for yourself, Cindy. I will have a deeper look in this query and propose a fix, best wishes, Jörg

webchills commented 2 years ago

Found the reason in includes/classes/observers/auto.vat_for_eu_countries.php: if ($this->vatNumber !== '' does not recognize NULL in the entry_vat_number field, so all customers with entry_vat_number_field NULL in table address_book get this message and as well VAT ID: shown during checkout and in emails. if ($this->vatNumber !== '' has to be replaced with if (!empty ($this->vatNumber))

line 106: if ((!empty($this->vatNumber) && $this->vatNumberStatus !== VatValidation::VAT_ADMIN_OVERRIDE && $this->vatNumberStatus !== VatValidation::VAT_VIES_OK)) {

line 155: if (!empty ($this->vatNumber)) {

line 491: if (!empty($this->vatNumber) || $current_page_base === FILENAME_ADDRESS_BOOK || $current_page_base === FILENAME_CHECKOUT_PAYMENT_ADDRESS) {