Hello,
I meet a bug with the error message of commerce_coupon_redeem_coupon_code() function. The $error is no sent back.
I made the call like this:
$error = '';
if (!empty($code)) {
$coupon = commerce_coupon_redeem_coupon_code($code, $order, $error);
...
}
I am specially in a error case where my coupon is not available anymore, because a usage per person limit.
So I'm supposed to get back $error = "Unable to redeem coupon."
With the debugger I see that the function is suppose to return the message t('Unable to redeem coupon.'); by the referenced variable error. But after pass in the &drupal_static function, the $error variable is no longer a referenced variable and out of the function commerce_coupon_redeem_coupon_code() my $error variable take his value of empty again.
Add to this, this function calls the commerce_coupon_evaluate_conditions() function, wich use a access to protected member "Type":
$coupon_wrapper->type->value()
With this, my function always return TRUE => and she shouldn't !
I fixed with:
$coupon_wrapper->type()
It solved the error. This error occured 3 times in the commerce_coupon.module file.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | no_error_message_returned-2597566-1.patch | 1004 bytes | paranojik |
Comments
Comment #2
paranojik commentedA tricky combination of pass-by-reference and return-by-reference :)
Here's a patch.
Comment #3
mwisner commentedPatch in #2 fixed the issue for me. Thanks!
Comment #4
mdupree commented#2 Works for me also, easy fix!
Comment #5
mdupree commentedComment #7
mglamanThanks!
Comment #8
torgospizzaI forgot to post here, that when this patch is applied the pane no longer updates, but I can't quite understand why. Has anyone else experienced that?