You are here

function uc_usps_rate_markup in Ubercart 7.3

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.

1 call to uc_usps_rate_markup()
uc_usps_quote in shipping/uc_usps/uc_usps.module
Callback for retrieving USPS shipping quote.
5 string references to 'uc_usps_rate_markup'
uc_usps_admin_settings in shipping/uc_usps/uc_usps.admin.inc
Configures USPS settings.
uc_usps_admin_settings_submit in shipping/uc_usps/uc_usps.admin.inc
Submit handler for uc_usps_admin_settings form.
uc_usps_admin_settings_validate in shipping/uc_usps/uc_usps.admin.inc
Validation handler for uc_usps_admin_settings form.
uc_usps_uninstall in shipping/uc_usps/uc_usps.install
Implements hook_uninstall().
uc_usps_update_7300 in shipping/uc_usps/uc_usps.install
Separates markup variables into rate_markup and weight_markup.

File

shipping/uc_usps/uc_usps.module, line 567
United States Postal Service (USPS) shipping quote module.

Code

function uc_usps_rate_markup($rate) {
  $markup = trim(variable_get('uc_usps_rate_markup', '0'));
  $type = variable_get('uc_usps_rate_markup_type', 'percentage');
  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;
  }
}