You are here

public function PriceDefaultFormatter::settingsSummary in Commerce Core 8.2

Returns a short summary for the current formatter settings.

If an empty result is returned, a UI can still be provided to display a settings form in case the formatter has configurable settings.

Return value

string[] A short summary of the formatter settings.

Overrides FormatterBase::settingsSummary

1 call to PriceDefaultFormatter::settingsSummary()
PriceCalculatedFormatter::settingsSummary in modules/order/src/Plugin/Field/FieldFormatter/PriceCalculatedFormatter.php
Returns a short summary for the current formatter settings.
1 method overrides PriceDefaultFormatter::settingsSummary()
PriceCalculatedFormatter::settingsSummary in modules/order/src/Plugin/Field/FieldFormatter/PriceCalculatedFormatter.php
Returns a short summary for the current formatter settings.

File

modules/price/src/Plugin/Field/FieldFormatter/PriceDefaultFormatter.php, line 113

Class

PriceDefaultFormatter
Plugin implementation of the 'commerce_price_default' formatter.

Namespace

Drupal\commerce_price\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = [];
  if ($this
    ->getSetting('strip_trailing_zeroes')) {
    $summary[] = $this
      ->t('Strip trailing zeroes after the decimal point.');
  }
  else {
    $summary[] = $this
      ->t('Do not strip trailing zeroes after the decimal point.');
  }
  $currency_display = $this
    ->getSetting('currency_display');
  $currency_display_options = [
    'symbol' => $this
      ->t('Symbol (e.g. "$")'),
    'code' => $this
      ->t('Currency code (e.g. "USD")'),
    'none' => $this
      ->t('None'),
  ];
  $summary[] = $this
    ->t('Currency display: @currency_display.', [
    '@currency_display' => $currency_display_options[$currency_display],
  ]);
  return $summary;
}