Skip to content

Commit

Permalink
Update AddressBook.php - Fix
Browse files Browse the repository at this point in the history
as $this->addresstype only returns the hardcoded string in english language. There is now a variable which holds the translated string for each type
  • Loading branch information
MLindenhofer authored Oct 23, 2023
1 parent 02c30c9 commit b16415d
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 b16415d

Please sign in to comment.