You are here

public function PadoAddToCartFormatter::settingsSummary in Commerce Product Add-on 8

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 AddToCartFormatter::settingsSummary

File

src/Plugin/Field/FieldFormatter/PadoAddToCartFormatter.php, line 61

Class

PadoAddToCartFormatter
Plugin implementation of the 'commerce_pado_add_to_cart' formatter.

Namespace

Drupal\commerce_pado\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = parent::settingsSummary();
  $add_on_field = $this
    ->getSetting('add_on_field');
  if (!empty($add_on_field)) {
    $summary[] = $this
      ->t('The selected product add-on field is @field.', [
      '@field' => $this
        ->getSetting('add_on_field'),
    ]);
  }
  else {
    $summary[] = $this
      ->t('Please select a product add-on field.');
  }
  if ($this
    ->getSetting('multiple')) {
    $summary[] = $this
      ->t('The customer can select multiple add-ons.');
  }
  else {
    $summary[] = $this
      ->t('The customer can select only one add-on.');
  }
  return $summary;
}