You are here

function uc_discounts_discount_amount_formatted in Ubercart Discounts (Alternative) 7.2

Format a discount amount as percentage or with currency symbol.

Parameters

object $discount: The loaded discount object.

Return value

string.

1 call to uc_discounts_discount_amount_formatted()
uc_discounts_admin_discounts_list in uc_discounts/uc_discounts.admin.inc
Generates admin page listing all saved discounts.

File

uc_discounts/uc_discounts.module, line 2470

Code

function uc_discounts_discount_amount_formatted($discount) {
  if (in_array($discount->discount_type, array(
    UC_DISCOUNTS_DISCOUNT_TYPE_PERCENTAGE_OFF,
    UC_DISCOUNTS_DISCOUNT_TYPE_PERCENTAGE_OFF_PER_QUALIFYING_ITEM,
  ))) {
    return $discount->discount_amount * 100 . '%';
  }
  elseif (in_array($discount->discount_type, array(
    UC_DISCOUNTS_DISCOUNT_TYPE_FIXED_AMOUNT_OFF,
    UC_DISCOUNTS_DISCOUNT_TYPE_FIXED_AMOUNT_OFF_PER_QUALIFYING_ITEM,
  ))) {
    return uc_currency_format($discount->discount_amount);
  }
  else {
    return $discount->discount_amount;
  }
}