Skip to content

Commit

Permalink
Changed "mrs" to "ms", removed "miss" and made salutations configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
aimeos committed Jan 17, 2021
1 parent 2655912 commit 6dd487c
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 61 deletions.
41 changes: 40 additions & 1 deletion client/html/src/Client/Html/Account/Profile/Address/Standard.php
Expand Up @@ -249,8 +249,47 @@ public function process()
public function addData( \Aimeos\MW\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\MW\View\Iface
{
$context = $this->getContext();
$config = $context->getConfig();
$cntl = \Aimeos\Controller\Frontend::create( $context, 'customer' );

/** client/html/common/address/salutations
* List of salutions the customers can select from in the HTML frontend
*
* The following salutations are available:
*
* * empty string for "unknown"
* * company
* * mr
* * ms
*
* You can modify the list of salutation codes and remove the ones
* which shouldn't be used or add new ones.
*
* @param array List of available salutation codes
* @since 2021.04
* @see client/html/account/profile/address/salutations
*/
$salutations = $config->get( 'client/html/common/address/salutations', ['', 'company', 'mr', 'ms'] );

/** client/html/account/profile/address/salutations
* List of salutions the customers can select from in their account
*
* The following salutations are available:
*
* * empty string for "unknown"
* * company
* * mr
* * ms
*
* You can modify the list of salutation codes and remove the ones
* which shouldn't be used or add new ones.
*
* @param array List of available salutation codes
* @since 2021.04
* @see client/html/common/address/salutations
*/
$salutations = $config->get( 'client/html/account/profile/address/salutations', $salutations );

$localeManager = \Aimeos\MShop::create( $context, 'locale' );
$languages = $localeManager->search( $localeManager->filter( true ) )
->col( 'locale.languageid', 'locale.languageid' );
Expand All @@ -274,7 +313,7 @@ public function addData( \Aimeos\MW\View\Iface $view, array &$tags = [], string
$view->addressDelivery = $deliveries;
$view->addressCountries = $view->config( 'client/html/checkout/address/countries', [] );
$view->addressStates = $view->config( 'client/html/checkout/address/states', [] );
$view->addressSalutations = array( 'company', 'mr', 'mrs' );
$view->addressSalutations = $salutations;
$view->addressLanguages = $languages;

return parent::addData( $view, $tags, $expire );
Expand Down
Expand Up @@ -261,6 +261,7 @@ public function addData( \Aimeos\MW\View\Iface $view, array &$tags = [], string
$view->addressBillingValues = array_merge( $values, $view->param( 'ca_billing_' . $id, [] ) );
$view->addressBillingOption = $view->param( 'ca_billingoption', $id );

$salutations = $context->getConfig()->get( 'client/html/common/address/salutations', ['', 'company', 'mr', 'ms'] );

/** client/html/checkout/standard/address/billing/salutations
* List of salutions the customer can select from for the billing address
Expand All @@ -270,16 +271,10 @@ public function addData( \Aimeos\MW\View\Iface $view, array &$tags = [], string
* * empty string for "unknown"
* * company
* * mr
* * mrs
* * miss
* * ms
*
* You can modify the list of salutation codes and remove the ones
* which shouldn't be used. Adding new salutations is a little bit
* more difficult because you have to adapt a few areas in the source
* code.
*
* Until 2015-02, the configuration option was available as
* "client/html/common/address/billing/salutations" starting from 2014-03.
* which shouldn't be used or add new ones.
*
* @param array List of available salutation codes
* @since 2015.02
Expand All @@ -290,8 +285,8 @@ public function addData( \Aimeos\MW\View\Iface $view, array &$tags = [], string
* @see client/html/checkout/standard/address/billing/optional
* @see client/html/checkout/standard/address/billing/hidden
* @see client/html/checkout/standard/address/countries
* @see client/html/common/address/salutations
*/
$salutations = array( 'company', 'mr', 'mrs' );
$view->addressBillingSalutations = $view->config( 'client/html/checkout/standard/address/billing/salutations', $salutations );

$mandatory = $view->config( 'client/html/checkout/standard/address/billing/mandatory', $this->mandatory );
Expand Down
Expand Up @@ -605,6 +605,7 @@ public function addData( \Aimeos\MW\View\Iface $view, array &$tags = [], string
$view->addressDeliveryStrings = $addrStrings;
$view->addressDeliveryValues = $addrValues;

$salutations = $context->getConfig()->get( 'client/html/common/address/salutations', ['', 'company', 'mr', 'ms'] );

/** client/html/checkout/standard/address/delivery/salutations
* List of salutions the customer can select from for the delivery address
Expand All @@ -614,16 +615,10 @@ public function addData( \Aimeos\MW\View\Iface $view, array &$tags = [], string
* * empty string for "unknown"
* * company
* * mr
* * mrs
* * miss
* * ms
*
* You can modify the list of salutation codes and remove the ones
* which shouldn't be used. Adding new salutations is a little bit
* more difficult because you have to adapt a few areas in the source
* code.
*
* Until 2015-02, the configuration option was available as
* "client/html/common/address/delivery/salutations" starting from 2014-03.
* which shouldn't be used or add new ones.
*
* @param array List of available salutation codes
* @since 2015.02
Expand All @@ -634,8 +629,8 @@ public function addData( \Aimeos\MW\View\Iface $view, array &$tags = [], string
* @see client/html/checkout/standard/address/delivery/optional
* @see client/html/checkout/standard/address/delivery/hidden
* @see client/html/checkout/standard/address/countries
* @see client/html/common/address/salutations
*/
$salutations = array( 'company', 'mr', 'mrs' );
$view->addressDeliverySalutations = $view->config( 'client/html/checkout/standard/address/delivery/salutations', $salutations );

$mandatory = $view->config( 'client/html/checkout/standard/address/delivery/mandatory', $this->mandatory );
Expand Down
13 changes: 6 additions & 7 deletions client/html/src/Client/Html/Email/Account/Standard.php
Expand Up @@ -427,21 +427,20 @@ protected function getSubClientNames() : array
*/
public function addData( \Aimeos\MW\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\MW\View\Iface
{
$addr = $view->get( 'extAddressItem' );
$list = array(
/// E-mail intro with first name (%1$s) and last name (%2$s)
\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_UNKNOWN => $view->translate( 'client', 'Dear %1$s %2$s' ),
/// E-mail intro with first name (%1$s) and last name (%2$s)
\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MR => $view->translate( 'client', 'Dear Mr %1$s %2$s' ),
/// E-mail intro with first name (%1$s) and last name (%2$s)
\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MRS => $view->translate( 'client', 'Dear Mrs %1$s %2$s' ),
/// E-mail intro with first name (%1$s) and last name (%2$s)
\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MISS => $view->translate( 'client', 'Dear Miss %1$s %2$s' ),
\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MS => $view->translate( 'client', 'Dear Ms %1$s %2$s' ),
);

if( isset( $view->extAddressItem ) && ( $addr = $view->extAddressItem ) && isset( $list[$addr->getSalutation()] ) ) {
if( $addr && isset( $list[$addr->getSalutation()] ) ) {
$view->emailIntro = sprintf( $list[$addr->getSalutation()], $addr->getFirstName(), $addr->getLastName() );
} elseif( $addr ) {
$view->emailIntro = sprintf( 'Dear %1$s %2$s', $addr->getFirstName(), $addr->getLastName() );
} else {
$view->emailIntro = $view->translate( 'client', 'Dear Sir or Madam' );
$view->emailIntro = $view->translate( 'client', 'Dear customer' );
}

return parent::addData( $view, $tags, $expire );
Expand Down
13 changes: 6 additions & 7 deletions client/html/src/Client/Html/Email/Delivery/Standard.php
Expand Up @@ -559,21 +559,20 @@ protected function getSubClientNames() : array
*/
public function addData( \Aimeos\MW\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\MW\View\Iface
{
$addr = $view->get( 'extAddressItem' );
$list = array(
/// E-mail intro with first name (%1$s) and last name (%2$s)
\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_UNKNOWN => $view->translate( 'client', 'Dear %1$s %2$s' ),
/// E-mail intro with first name (%1$s) and last name (%2$s)
\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MR => $view->translate( 'client', 'Dear Mr %1$s %2$s' ),
/// E-mail intro with first name (%1$s) and last name (%2$s)
\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MRS => $view->translate( 'client', 'Dear Mrs %1$s %2$s' ),
/// E-mail intro with first name (%1$s) and last name (%2$s)
\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MISS => $view->translate( 'client', 'Dear Miss %1$s %2$s' ),
\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MS => $view->translate( 'client', 'Dear Ms %1$s %2$s' ),
);

if( isset( $view->extAddressItem ) && ( $addr = $view->extAddressItem ) && isset( $list[$addr->getSalutation()] ) ) {
if( $addr && isset( $list[$addr->getSalutation()] ) ) {
$view->emailIntro = sprintf( $list[$addr->getSalutation()], $addr->getFirstName(), $addr->getLastName() );
} elseif( $addr ) {
$view->emailIntro = sprintf( 'Dear %1$s %2$s', $addr->getFirstName(), $addr->getLastName() );
} else {
$view->emailIntro = $view->translate( 'client', 'Dear Sir or Madam' );
$view->emailIntro = $view->translate( 'client', 'Dear customer' );
}


Expand Down
13 changes: 6 additions & 7 deletions client/html/src/Client/Html/Email/Payment/Standard.php
Expand Up @@ -504,21 +504,20 @@ protected function getSubClientNames() : array
*/
public function addData( \Aimeos\MW\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\MW\View\Iface
{
$addr = $view->get( 'extAddressItem' );
$list = array(
/// E-mail intro with first name (%1$s) and last name (%2$s)
\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_UNKNOWN => $view->translate( 'client', 'Dear %1$s %2$s' ),
/// E-mail intro with first name (%1$s) and last name (%2$s)
\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MR => $view->translate( 'client', 'Dear Mr %1$s %2$s' ),
/// E-mail intro with first name (%1$s) and last name (%2$s)
\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MRS => $view->translate( 'client', 'Dear Mrs %1$s %2$s' ),
/// E-mail intro with first name (%1$s) and last name (%2$s)
\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MISS => $view->translate( 'client', 'Dear Miss %1$s %2$s' ),
\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MS => $view->translate( 'client', 'Dear Ms %1$s %2$s' ),
);

if( isset( $view->extAddressItem ) && ( $addr = $view->extAddressItem ) && isset( $list[$addr->getSalutation()] ) ) {
if( $addr && isset( $list[$addr->getSalutation()] ) ) {
$view->emailIntro = sprintf( $list[$addr->getSalutation()], $addr->getFirstName(), $addr->getLastName() );
} elseif( $addr ) {
$view->emailIntro = sprintf( 'Dear %1$s %2$s', $addr->getFirstName(), $addr->getLastName() );
} else {
$view->emailIntro = $view->translate( 'client', 'Dear Sir or Madam' );
$view->emailIntro = $view->translate( 'client', 'Dear customer' );
}


Expand Down
13 changes: 6 additions & 7 deletions client/html/src/Client/Html/Email/Subscription/Standard.php
Expand Up @@ -427,21 +427,20 @@ protected function getSubClientNames() : array
*/
public function addData( \Aimeos\MW\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\MW\View\Iface
{
$addr = $view->get( 'extAddressItem' );
$list = array(
/// E-mail intro with first name (%1$s) and last name (%2$s)
\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_UNKNOWN => $view->translate( 'client', 'Dear %1$s %2$s' ),
/// E-mail intro with first name (%1$s) and last name (%2$s)
\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MR => $view->translate( 'client', 'Dear Mr %1$s %2$s' ),
/// E-mail intro with first name (%1$s) and last name (%2$s)
\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MRS => $view->translate( 'client', 'Dear Mrs %1$s %2$s' ),
/// E-mail intro with first name (%1$s) and last name (%2$s)
\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MISS => $view->translate( 'client', 'Dear Miss %1$s %2$s' ),
\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MS => $view->translate( 'client', 'Dear Ms %1$s %2$s' ),
);

if( isset( $view->extAddressItem ) && ( $addr = $view->extAddressItem ) && isset( $list[$addr->getSalutation()] ) ) {
if( $addr && isset( $list[$addr->getSalutation()] ) ) {
$view->emailIntro = sprintf( $list[$addr->getSalutation()], $addr->getFirstName(), $addr->getLastName() );
} elseif( $addr ) {
$view->emailIntro = sprintf( 'Dear %1$s %2$s', $addr->getFirstName(), $addr->getLastName() );
} else {
$view->emailIntro = $view->translate( 'client', 'Dear Sir or Madam' );
$view->emailIntro = $view->translate( 'client', 'Dear customer' );
}

return parent::addData( $view, $tags, $expire );
Expand Down
13 changes: 6 additions & 7 deletions client/html/src/Client/Html/Email/Voucher/Standard.php
Expand Up @@ -427,21 +427,20 @@ protected function getSubClientNames() : array
*/
public function addData( \Aimeos\MW\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\MW\View\Iface
{
$addr = $view->get( 'extAddressItem' );
$list = array(
/// E-mail intro with first name (%1$s) and last name (%2$s)
\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_UNKNOWN => $view->translate( 'client', 'Dear %1$s %2$s' ),
/// E-mail intro with first name (%1$s) and last name (%2$s)
\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MR => $view->translate( 'client', 'Dear Mr %1$s %2$s' ),
/// E-mail intro with first name (%1$s) and last name (%2$s)
\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MRS => $view->translate( 'client', 'Dear Mrs %1$s %2$s' ),
/// E-mail intro with first name (%1$s) and last name (%2$s)
\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MISS => $view->translate( 'client', 'Dear Miss %1$s %2$s' ),
\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MS => $view->translate( 'client', 'Dear Ms %1$s %2$s' ),
);

if( isset( $view->extAddressItem ) && ( $addr = $view->extAddressItem ) && isset( $list[$addr->getSalutation()] ) ) {
if( $addr && isset( $list[$addr->getSalutation()] ) ) {
$view->emailIntro = sprintf( $list[$addr->getSalutation()], $addr->getFirstName(), $addr->getLastName() );
} elseif( $addr ) {
$view->emailIntro = sprintf( 'Dear %1$s %2$s', $addr->getFirstName(), $addr->getLastName() );
} else {
$view->emailIntro = $view->translate( 'client', 'Dear Sir or Madam' );
$view->emailIntro = $view->translate( 'client', 'Dear customer' );
}

return parent::addData( $view, $tags, $expire );
Expand Down
13 changes: 6 additions & 7 deletions client/html/src/Client/Html/Email/Watch/Standard.php
Expand Up @@ -428,21 +428,20 @@ protected function getSubClientNames() : array
*/
public function addData( \Aimeos\MW\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\MW\View\Iface
{
$addr = $view->get( 'extAddressItem' );
$list = array(
/// E-mail intro with first name (%1$s) and last name (%2$s)
\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_UNKNOWN => $view->translate( 'client', 'Dear %1$s %2$s' ),
/// E-mail intro with first name (%1$s) and last name (%2$s)
\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MR => $view->translate( 'client', 'Dear Mr %1$s %2$s' ),
/// E-mail intro with first name (%1$s) and last name (%2$s)
\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MRS => $view->translate( 'client', 'Dear Mrs %1$s %2$s' ),
/// E-mail intro with first name (%1$s) and last name (%2$s)
\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MISS => $view->translate( 'client', 'Dear Miss %1$s %2$s' ),
\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MS => $view->translate( 'client', 'Dear Ms %1$s %2$s' ),
);

if( isset( $view->extAddressItem ) && ( $addr = $view->extAddressItem ) && isset( $list[$addr->getSalutation()] ) ) {
if( $addr && isset( $list[$addr->getSalutation()] ) ) {
$view->emailIntro = sprintf( $list[$addr->getSalutation()], $addr->getFirstName(), $addr->getLastName() );
} elseif( $addr ) {
$view->emailIntro = sprintf( 'Dear %1$s %2$s', $addr->getFirstName(), $addr->getLastName() );
} else {
$view->emailIntro = $view->translate( 'client', 'Dear Sir or Madam' );
$view->emailIntro = $view->translate( 'client', 'Dear customer' );
}

return parent::addData( $view, $tags, $expire );
Expand Down

0 comments on commit 6dd487c

Please sign in to comment.