You are here

protected function USPSRateBase::rateMarkup in Ubercart 8.4

Modifies the rate received from USPS before displaying to the customer.

Parameters

$rate: Shipping rate without any rate markup.

Return value

Shipping rate after markup.

3 calls to USPSRateBase::rateMarkup()
USPSDomesticRate::quote in shipping/uc_usps/src/Plugin/Ubercart/ShippingQuote/USPSDomesticRate.php
Callback for retrieving USPS shipping quote.
USPSInternationalRate::quote in shipping/uc_usps/src/Plugin/Ubercart/ShippingQuote/USPSInternationalRate.php
Callback for retrieving USPS shipping quote.
USPSRateBase::quote in shipping/uc_usps/src/Plugin/Ubercart/ShippingQuote/USPSRateBase.php
Callback for retrieving USPS shipping quote.

File

shipping/uc_usps/src/Plugin/Ubercart/ShippingQuote/USPSRateBase.php, line 363

Class

USPSRateBase
Common functionality for USPS shipping quotes plugins.

Namespace

Drupal\uc_usps\Plugin\Ubercart\ShippingQuote

Code

protected function rateMarkup($rate) {
  $usps_config = \Drupal::config('uc_usps.settings');
  $markup = trim($usps_config
    ->get('rate_markup'));
  $type = $usps_config
    ->get('rate_markup_type');
  if (is_numeric($markup)) {
    switch ($type) {
      case 'percentage':
        return $rate + $rate * floatval($markup) / 100;
      case 'multiplier':
        return $rate * floatval($markup);
      case 'currency':
        return $rate + floatval($markup);
    }
  }
  else {
    return $rate;
  }
}