You are here

public function PriceCalculatedFormatter::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 PriceDefaultFormatter::settingsSummary

File

modules/order/src/Plugin/Field/FieldFormatter/PriceCalculatedFormatter.php, line 147

Class

PriceCalculatedFormatter
Alternative implementation of the 'commerce_price_calculated' formatter.

Namespace

Drupal\commerce_order\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = parent::settingsSummary();
  $enabled_adjustment_types = array_filter($this
    ->getSetting('adjustment_types'));
  foreach ($this->adjustmentTypeManager
    ->getDefinitions() as $plugin_id => $definition) {
    if (in_array($plugin_id, $enabled_adjustment_types)) {
      $summary[] = $this
        ->t('Apply @label to the calculated price', [
        '@label' => $definition['plural_label'],
      ]);
    }
  }
  return $summary;
}