You are here

public function VariationAddToCartFormatter::settingsSummary in Commerce Variation Add to Cart 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 FormatterBase::settingsSummary

File

src/Plugin/Field/FieldFormatter/VariationAddToCartFormatter.php, line 135

Class

VariationAddToCartFormatter
Plugin implementation of the 'variation_add_to_cart_form' formatter.

Namespace

Drupal\commerce_variation_add_to_cart\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = [];
  if ($this
    ->getSetting('show_title')) {
    $summary[] = $this
      ->t('Show variation title.');
  }
  else {
    $summary[] = $this
      ->t('Do not show variation title.');
  }
  if ($this
    ->getSetting('show_quantity')) {
    $summary[] = $this
      ->t('Show quantity box.');
  }
  else {
    $summary[] = $this
      ->t('Do not show quantity box.');
  }
  if ($this
    ->getSetting('show_price')) {
    $summary[] = $this
      ->t('Show price.');
  }
  else {
    $summary[] = $this
      ->t('Do not show price.');
  }
  if ($this
    ->getSetting('show_currency')) {
    $summary[] = $this
      ->t('Show currency.');
  }
  else {
    $summary[] = $this
      ->t('Do not show currency.');
  }
  if ($this
    ->getSetting('price_format') == 2) {
    $summary[] = $this
      ->t('Price format 0.00');
  }
  else {
    $summary[] = $this
      ->t('Price format 0');
  }
  return $summary;
}