You are here

function hook_uc_coupon_revalidate in Ubercart Discount Coupons 7.3

Same name and namespace in other branches
  1. 7.2 uc_coupon.api.php \hook_uc_coupon_revalidate()

hook_uc_coupon_revalidate().

Invoked whenever the coupons added to the current session are about to be validated.

Modules implementing this hook may add or remove coupon codes from the session via calls to uc_coupon_session_add() or uc_coupon_session_clear().

Parameters

$order: The order against which the coupon will be validated.

1 function implements hook_uc_coupon_revalidate()

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_revalidate in uc_coupon_workflow/uc_coupon_workflow.module
Implements hook_uc_coupon_revalidate().
1 invocation of hook_uc_coupon_revalidate()
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.

File

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

Code

function hook_uc_coupon_revalidate($order) {

  // Add a code if there are both a widget and a doohickey in the cart.
  $gotwidget = FALSE;
  $gotdoohickey = FALSE;
  foreach ($order->products as $product) {
    $node = node_load($product->nid);
    if ($node) {
      if ($node->type == 'widget') {
        $gotwidget = TRUE;
      }
      elseif ($node->type == 'doohickey') {
        $gotdoohickey = TRUE;
      }
      if ($gotwidget && $gotdoohickey) {
        uc_coupon_session_add('JACKPOT', 'auto');
        return;
      }
    }
  }
}