You are here

function _uc_coupon_format_discount in Ubercart Discount Coupons 7.3

Same name and namespace in other branches
  1. 7.2 uc_coupon.module \_uc_coupon_format_discount()

Format a coupon's value depending on the type, optionally including currency symbols.

2 calls to _uc_coupon_format_discount()
theme_uc_coupon_discount in ./uc_coupon.module
Theme for a coupon discount.
uc_coupon_add_form in ./uc_coupon.admin.inc
Coupon add/edit form.

File

./uc_coupon.module, line 339
Provides discount codes and gift certificates for Ubercart.

Code

function _uc_coupon_format_discount($coupon, $currency = TRUE) {
  switch ($coupon->type) {
    case 'price':
    case 'credit':
      return $currency ? uc_currency_format($coupon->value) : $coupon->value;
    case 'percentage':
      return (double) $coupon->value . '%';
    case 'set_price':
      return '=' . ($currency ? uc_currency_format($coupon->value) : $coupon->value);
  }
}