You are here

function theme_codeless_discounts_field_get_codeless_discount_html_for_product in Ubercart Discounts (Alternative) 7.2

Same name and namespace in other branches
  1. 6.2 codeless_discounts_field/codeless_discounts_field.module \theme_codeless_discounts_field_get_codeless_discount_html_for_product()
1 theme call to theme_codeless_discounts_field_get_codeless_discount_html_for_product()
codeless_discounts_field_field in codeless_discounts_field/codeless_discounts_field.module
Implementation of hook_field()

File

codeless_discounts_field/codeless_discounts_field.module, line 107
Attach automatic (codeless) discounts to products using fields.

Code

function theme_codeless_discounts_field_get_codeless_discount_html_for_product($product) {
  $discounts = uc_discounts_get_codeless_discounts_for_product($product);
  if (empty($discounts)) {
    return "";
  }
  $descriptions = array();
  foreach ($discounts as $discount) {
    $description = $discount->short_description;
    if ($discount->has_expiration) {
      $description .= " (" . t("Expires:") . " " . date("Y-m-d H:i", $discount->expiration) . ")";
    }
    $descriptions[] = $description;
  }
  return join("<br/>", $descriptions);
}