Skip to content

Commit

Permalink
Fix $this->addresstype only contains EN value (#797)
Browse files Browse the repository at this point in the history
* Update AddressBook.php SS4

Update AddressBook translation string by adding the addresstype -  for SS4 version

* 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
  • Loading branch information
MLindenhofer committed Oct 27, 2023
1 parent 6be2a2b commit bf5bf26
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Checkout/Component/AddressBook.php
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 bf5bf26

Please sign in to comment.