You are here

function _uc_coupon_options_list in Ubercart Discount Coupons 7.2

Same name and namespace in other branches
  1. 7.3 uc_coupon.module \_uc_coupon_options_list()

Helper function to create a list of coupons for form elements.

Parameters

$coupons: An array of validated coupon objects to include in the list.

$in_session: TRUE to include only coupons currently added to the session. FALSE to include those not in the session (e.g. automatic coupons).

Return value

An associative array mapping coupon code to coupon title.

3 calls to _uc_coupon_options_list()
uc_checkout_pane_coupon_automatic in ./uc_coupon.module
A checkout pane listing any automatic discounts.
uc_coupon_form in ./uc_coupon.module
Form builder for the uc_coupon form.
uc_coupon_uc_cart_pane in ./uc_coupon.module
Implements hook_uc_cart_pane().

File

./uc_coupon.module, line 1169

Code

function _uc_coupon_options_list($coupons, $in_session = TRUE) {
  $options = array();
  if (!empty($coupons)) {
    foreach ($coupons as $coupon) {
      if (!$in_session xor uc_coupon_session_get($coupon->code)) {
        $options[$coupon->code] = $coupon->title;
      }
    }
  }
  return $options;
}