You are here

function hook_uc_coupon_remove in Ubercart Discount Coupons 7.2

Same name and namespace in other branches
  1. 7.3 uc_coupon.api.php \hook_uc_coupon_remove()

hook_uc_coupon_remove().

Invoked whenever a previously valid coupon is removed.

Note that you should not do anything in your hoook implementation which causes the current cart contents to be rebuilt. This includes calls to uc_cart_add_item() without explicitly setting the $rebuild argument to false. And, since coupons may be submitted on the checkout page after the cart contents are frozen, updates to the cart contents may fail under some circumstances anyway.

Parameters

$coupon: The coupon which was removed.

1 function implements hook_uc_coupon_remove()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

uc_coupon_workflow_uc_coupon_remove in uc_coupon_workflow/uc_coupon_workflow.module
Implements hook_uc_coupon_remove().
3 invocations of hook_uc_coupon_remove()
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_uc_update_cart_item in ./uc_coupon.module
Implements hook_uc_update_cart_item(). Remove a coupon from the order when the "Remove" button is clicked.

File

./uc_coupon.api.php, line 199
Ubercart Discount Coupon module api/hooks. Version 7.x-2.x

Code

function hook_uc_coupon_remove($coupon) {

  // Revoke a role for the active user when a particular coupon is removed.
  global $user;
  if ($coupon->cid == 99 && $user->uid != 0) {
    $roles = $user->roles;
    $key = array_search('My Special Role', $roles);
    if ($key !== FALSE) {
      unset($roles[$key]);
      user_save($user, array(
        'roles' => $roles,
      ));
    }
  }
}