Skip to content

Commit

Permalink
OXDEV-8847 Fix checkout with no salutation included
Browse files Browse the repository at this point in the history
  • Loading branch information
TitaKoleva authored and NikolaIvanovski committed Oct 28, 2024
1 parent d19e444 commit f060c31
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [2.2.0] - unreleased

### Fixed
- Shop owners suggested Pick Up Address cannot be used for order if no salutation is included [0007734](https://bugs.oxid-esales.com/view.php?id=7734)

## [2.2.0-rc.1] - 2024-10-17

### Added
Expand Down
22 changes: 22 additions & 0 deletions src/Component/UserComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
namespace OxidEsales\GeoBlocking\Component;

use OxidEsales\Eshop\Application\Model\Address;
use OxidEsales\Eshop\Core\Form\FormFields;
use OxidEsales\Eshop\Core\Form\FormFieldsTrimmer;
use OxidEsales\Eshop\Core\Registry;
use OxidEsales\GeoBlocking\Service\CountryToShopService;

Expand All @@ -26,6 +28,7 @@ class UserComponent extends UserComponent_parent
public function changeUserWithoutRedirect()
{
$deliveryAddressInfo = Registry::getRequest()->getRequestEscapedParameter('deladr', '');
$deliveryAddressInfo = $this->trimAddress($deliveryAddressInfo);
$countryToShop = $this->oeGeoBlockingCreateCountryToShopByAddressId(
Registry::getRequest()->getRequestEscapedParameter('oxaddressid', '')
);
Expand Down Expand Up @@ -76,4 +79,23 @@ private function oeGeoBlockingCreateCountryToShopByAddressId($addressId)
$countryToShop = $countryToShopService->getByAddressId($addressId);
return $countryToShop;
}

/**
* Returns trimmed address.
*
* @param array $address
*
* @return array
*/
private function trimAddress($address)
{
if (is_array($address)) {
$fields = oxNew(FormFields::class, $address);
$trimmer = oxNew(FormFieldsTrimmer::class);

$address = (array)$trimmer->trim($fields);
}

return $address;
}
}
16 changes: 16 additions & 0 deletions tests/Integration/Component/UserComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,22 @@ public function testChangeUserWithoutRedirectWhenAllowedToChangeAddressData()
$this->assertNull($errors);
}

public function testChangeUserWithoutRedirectWithWhiteSpacesInAddress()
{
/** @var \OxidEsales\GeoBlocking\Component\UserComponent $userComponent */
$userComponent = oxNew(UserComponent::class);
$_GET['oxaddressid'] = 'address_id';
$_GET['deladr'] = [
"oxaddress__oxsal" => " ",
"oxaddress__oxuserid" => " user_id ",
"oxaddress__oxcountryid" => " country_id"
];

$this->assertNotFalse($userComponent->changeUserWithoutRedirect());
$errors = Registry::getSession()->getVariable('Errors');
$this->assertNull($errors);
}

public function testDeleteShippingAddressWhenNotAllowed()
{
$_GET['oxaddressid'] = 'address_id';
Expand Down

0 comments on commit f060c31

Please sign in to comment.