You are here

public function StockLevelWidgetBase::settingsSummary in Commerce Stock 8

Returns a short summary for the current widget settings.

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

Return value

array A short summary of the widget settings.

Overrides WidgetBase::settingsSummary

File

modules/field/src/Plugin/Field/FieldWidget/StockLevelWidgetBase.php, line 76

Class

StockLevelWidgetBase
Provides the base structure for commerce stock level widgets.

Namespace

Drupal\commerce_stock_field\Plugin\Field\FieldWidget

Code

public function settingsSummary() {
  $summary = [];
  if ($this
    ->getSetting('step') == 1) {
    $summary[] = $this
      ->t('Decimal stock levels not allowed');
  }
  else {
    $summary[] = $this
      ->t('Decimal stock levels allowed');
    $summary[] = $this
      ->t('Step: @step', [
      '@step' => $this
        ->getSetting('step'),
    ]);
  }
  $summary[] = $this
    ->t('Default transaction note: @transaction_note', [
    '@transaction_note' => $this
      ->getSetting('default_transaction_note'),
  ]);
  $summary[] = $this
    ->t('Custom transaction note @allowed allowed.', [
    '@allowed' => $this
      ->getSetting('custom_transaction_note') ? '' : 'not',
  ]);
  return $summary;
}