You are here

function uc_coupon_session_get in Ubercart Discount Coupons 7.3

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

Checks to see if a given code is present in the session, or returns an associative array of all codes in the session.

Parameters

$code: (optional) The code to chec for. If not specified, will return all codes.

Return value

If a code is specified, returns TRUE if that code exists in the session, FALSE otherwise. If no code is specified, returns an array of the form $code=>$op for all codes in the session.

5 calls to uc_coupon_session_get()
uc_coupon_form in ./uc_coupon.module
Form builder for the uc_coupon form.
uc_coupon_form_submit in ./uc_coupon.module
Submit handler for the uc_coupon form.
uc_coupon_session_validate in ./uc_coupon.module
Validates all coupons in the current session. The validated coupons are statically cached for each request. The cache is rebuilt the first time this function is called, or every time the cart contents are rebuilt.
_uc_coupon_cart_item in ./uc_coupon.module
Creates a fake cart-item corrresponding to this coupon, allowing this coupon to be displayed in the cart.
_uc_coupon_options_list in ./uc_coupon.module
Helper function to create a list of coupons for form elements.

File

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

Code

function uc_coupon_session_get($code = NULL) {
  if (isset($code)) {
    return isset($_SESSION['uc_coupons'][$code]);
  }
  elseif (isset($_SESSION['uc_coupons'])) {
    return $_SESSION['uc_coupons'];
  }
  else {
    return array();
  }
}