From 91bfbf034f341ef1d0473e8f1572701bdbc0b422 Mon Sep 17 00:00:00 2001 From: Eneias Ramos de Melo Date: Wed, 29 Jun 2022 19:27:33 -0300 Subject: [PATCH] =?UTF-8?q?Adicionado=20rotina=20para=20remo=C3=A7=C3=A3o?= =?UTF-8?q?=20de=20acentua=C3=A7=C3=A3o=20antes=20de=20enviar=20para=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RicardoMartins/PagSeguro/Helper/Params.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/code/community/RicardoMartins/PagSeguro/Helper/Params.php b/app/code/community/RicardoMartins/PagSeguro/Helper/Params.php index 6bdf8d8e..d0730773 100644 --- a/app/code/community/RicardoMartins/PagSeguro/Helper/Params.php +++ b/app/code/community/RicardoMartins/PagSeguro/Helper/Params.php @@ -222,7 +222,7 @@ public function getAddressParams(Mage_Sales_Model_Order $order, $type) $addressComplement = $this->_getAddressAttributeValue($address, $addressComplementAttribute); $addressDistrict = $this->_getAddressAttributeValue($address, $addressNeighborhoodAttribute); $addressPostalCode = $digits->filter($address->getPostcode()); - $addressCity = $address->getCity(); + $addressCity = $this->removeAccents($address->getCity()); $addressState = $this->getStateCode($address->getRegion()); @@ -355,6 +355,11 @@ public function stripAccents($string) return preg_replace('/[`^~\'"]/', null, iconv('UTF-8', 'ASCII//TRANSLIT', $string)); } + public function removeAccents($text) + { + return Mage::helper('core')->removeAccents($text); + } + /** * Calculates the "Extra" value that corresponds to Tax values minus Discount given * It makes the correct discount to be shown correctly on PagSeguro @@ -525,13 +530,17 @@ protected function _getShippingType(Mage_Sales_Model_Order $order) protected function _getAddressAttributeValue($address, $attributeId) { $isStreetline = preg_match('/^street_(\d{1})$/', $attributeId, $matches); + $result = ''; if ($isStreetline !== false && isset($matches[1])) { //uses streetlines - return $address->getStreet(intval($matches[1])); + $result = $address->getStreet(intval($matches[1])); } else if ($attributeId == '') { //do not tell pagseguro return ''; + } else { + $result = (string)$address->getData($attributeId); } - return (string)$address->getData($attributeId); + + return $this->removeAccents($result); } /**