You are here

function bat_options_get_operation_label in Booking and Availability Management Tools for Drupal 8

Same name and namespace in other branches
  1. 7 modules/bat_options/bat_options.module \bat_options_get_operation_label()

Given an option, return a string that explains the operation.

File

modules/bat_options/bat_options.module, line 81

Code

function bat_options_get_operation_label($option) {
  $label = '';
  $currency_symbol = '$';
  switch ($option['operation']) {
    case 'add':
      $label = t('+@amount@currency_symbol to price', [
        '@amount' => $option['value'],
        '@currency_symbol' => $currency_symbol,
      ]);
      break;
    case 'add-daily':
      $label = t('+@amount@currency_symbol per night to price', [
        '@amount' => $option['value'],
        '@currency_symbol' => $currency_symbol,
      ]);
      break;
    case 'sub-daily':
      $label = t('-@amount@currency_symbol per night from price', [
        '@amount' => $option['value'],
        '@currency_symbol' => $currency_symbol,
      ]);
      break;
    case 'replace':
      $label = t('Replace price with @amount@currency_symbol', [
        '@amount' => $option['value'],
        '@currency_symbol' => $currency_symbol,
      ]);
      break;
    case 'increase':
      $label = t('Increase price by @amount%', [
        '@amount' => $option['value'],
      ]);
      break;
    case 'decrease':
      $label = t('Decrease price by @amount%', [
        '@amount' => $option['value'],
      ]);
      break;
    case 'sub':
      $label = t('-@amount@currency_symbol from price', [
        '@amount' => $option['value'],
        '@currency_symbol' => $currency_symbol,
      ]);
      break;
  }
  return $label;
}