Skip to content

Commit

Permalink
Merge pull request #1 from MLindenhofer/MLindenhofer-TranslateAddress…
Browse files Browse the repository at this point in the history
…TypeFix

Update AddressBook.php - Fix
  • Loading branch information
MLindenhofer authored Oct 23, 2023
2 parents 02c30c9 + b16415d commit b43590c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Checkout/Component/AddressBook.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,19 @@ public function getExistingAddressFields()
$member = Security::getCurrentUser();
if ($member && $member->AddressBook()->exists()) {
$addressoptions = $member->AddressBook()->sort('Created', 'DESC')->map('ID', 'toString')->toArray();
$addressoptions['newaddress'] = _t('SilverShop\Model\Address.CreateNewAddress', 'Create new {AddressType} address', '', ["AddressType" => $this->addresstype]);

$translatedAddressType = $this->addresstype;
if ($this->addresstype === 'Billing'){
$translatedAddressType = _t('SilverShop\Model\Address.BillingAddress', $this->addresstype);
}
if ($this->addresstype === 'Shipping'){
$translatedAddressType = _t('SilverShop\Model\Address.ShippingAddress', $this->addresstype);
}

$addressoptions['newaddress'] = _t('SilverShop\Model\Address.CreateNewAddress', 'Create new {AddressType} address', '', ["AddressType" => $translatedAddressType]);
$fieldtype = count($addressoptions) > 3 ? DropdownField::class : OptionsetField::class;

$label = _t("SilverShop\Model\Address.Existing{$this->addresstype}Address", "Existing {$this->addresstype} Address");
$label = _t("SilverShop\Model\Address.Existing{$this->addresstype}Address", "Existing {$translatedAddressType} Address");

return FieldList::create(
$fieldtype::create(
Expand Down

0 comments on commit b43590c

Please sign in to comment.