From 2672be1a71a050fe4bc3365f39c3a37704f84cd3 Mon Sep 17 00:00:00 2001 From: rafael-merola Date: Mon, 9 Jan 2023 11:56:05 -0300 Subject: [PATCH] Fix empty cpf/VAT number error handling --- Helper/Data.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Helper/Data.php b/Helper/Data.php index 2222076..0dfb905 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -611,7 +611,13 @@ public function getBuyer($order, $quote = null) $buyerFirstname = $billingAddress->getFirstname(); $buyerLastname = $billingAddress->getLastname(); - $buyerDocument = $this->_formatTaxVat($taxvat); + $buyerDocument = !empty($taxvat) ? $this->_formatTaxVat($taxvat) : false; + if(!$buyerDocument) + { + throw new \Magento\Framework\Exception\LocalizedException( + __('It is necessary to put CPF/VAT Number in your registration to finalize the purchase.') + ); + } $buyerEmail = $billingAddress->getEmail(); $buyerPhone = $this->_extractPhone($billingAddress->getTelephone());