Skip to content

Commit b16415d

Browse files
authored
Update AddressBook.php - Fix
as $this->addresstype only returns the hardcoded string in english language. There is now a variable which holds the translated string for each type
1 parent 02c30c9 commit b16415d

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/Checkout/Component/AddressBook.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,19 @@ public function getExistingAddressFields()
7272
$member = Security::getCurrentUser();
7373
if ($member && $member->AddressBook()->exists()) {
7474
$addressoptions = $member->AddressBook()->sort('Created', 'DESC')->map('ID', 'toString')->toArray();
75-
$addressoptions['newaddress'] = _t('SilverShop\Model\Address.CreateNewAddress', 'Create new {AddressType} address', '', ["AddressType" => $this->addresstype]);
75+
76+
$translatedAddressType = $this->addresstype;
77+
if ($this->addresstype === 'Billing'){
78+
$translatedAddressType = _t('SilverShop\Model\Address.BillingAddress', $this->addresstype);
79+
}
80+
if ($this->addresstype === 'Shipping'){
81+
$translatedAddressType = _t('SilverShop\Model\Address.ShippingAddress', $this->addresstype);
82+
}
83+
84+
$addressoptions['newaddress'] = _t('SilverShop\Model\Address.CreateNewAddress', 'Create new {AddressType} address', '', ["AddressType" => $translatedAddressType]);
7685
$fieldtype = count($addressoptions) > 3 ? DropdownField::class : OptionsetField::class;
7786

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

8089
return FieldList::create(
8190
$fieldtype::create(

0 commit comments

Comments
 (0)