I have tried to implement hook uc_coupon_validate in my module but it doesn't work. I have this code:

<?php
function mymodule_uc_coupon_validate($coupon, $order, $account) {
    watchdog('mymodule', 'uc_coupon hook');
}
?>

I have tried to find all hooks in module uc_coupon with searching for string "module_invoke_all". The search didn't find such a part of code: "module_invoke_all('uc_coupon_validate', ..), so I think the function is not applied as hook.

thanks for any help
Tomas

Comments

wodenx’s picture

Category: bug » support

The hook is invoked at line 661ff of uc_coupon.module

  // Invoke validation hook.
  foreach (module_implements('uc_coupon_validate') as $module) {
    $callback = $module . '_uc_coupon_validate';
    $result = $callback($coupon, $order, $account);

However, if the coupon does not exist in the system, is not active or has expired, validation will fail before the hook is invoked. If you want to do custom validation you need to create an active coupon that is not limited by date.