You are here

protected function UPSRateBase::weightMarkup in Ubercart 8.4

Modifies the weight of shipment before sending to UPS for a quote.

Parameters

float $weight: Shipping weight without any weight markup.

Return value

float Shipping weight after markup.

File

shipping/uc_ups/src/Plugin/Ubercart/ShippingQuote/UPSRateBase.php, line 395

Class

UPSRateBase
Common functionality for UPS shipping quotes plugins.

Namespace

Drupal\uc_ups\Plugin\Ubercart\ShippingQuote

Code

protected function weightMarkup($weight) {
  $ups_config = \Drupal::config('uc_ups.settings');
  $markup = trim($ups_config
    ->get('weight_markup'));
  $type = $ups_config
    ->get('weight_markup_type');
  if (is_numeric($markup)) {
    switch ($type) {
      case 'percentage':
        return $weight + $weight * floatval($markup) / 100;
      case 'multiplier':
        return $weight * floatval($markup);
      case 'mass':
        return $weight + floatval($markup);
    }
  }
  else {
    return $weight;
  }
}