Problem/Motivation
User attempts to redeem coupons may fail because the associated discount condition fails.
Today this results in a generic error "Unable to redeem coupon" that offers no guidance as to what the user should do.
This is a usability and customer service problem.
Proposed resolution
CAUSE:
commerce_coupon_pane_checkout_form() checks drupal_static('commerce_coupon_error_' . strtolower($code)). That's fine for coupon conditions where the coupon code is known, and the appropriate commerce_coupon_error_X can be set. Discount conditions have no idea which particular coupon code triggered them, so they cannot set this static variable.
PROPOSED RESOLUTION:
Have commerce_coupon_pane_checkout_form() also check drupal_static('commerce_coupon_error_discount_conditions'), a new static variable that can be set by discount conditions if they want to expose more specific (and more helpful) error information to users.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | coupon_pane_checkout_form-2925117-3.patch | 922 bytes | josephr5000 |
Comments
Comment #2
josephr5000 commentedComment #3
josephr5000 commentedComment #4
josephr5000 commentedComment #5
josephr5000 commentedReconsidered: this is probably more accurately filed as a feature request than as a bug.
Comment #6
deggertsen commentedI agree with this. I definitely think we need more options for customization of coupon errors.
Comment #7
rar commentedI agree this is needed.
It would be nice for clients, when creating a coupon, to have the ability to type in an error message that is displayed when the coupon's conditions don't match but someone tries it anyway. Something like "I'm sorry - this coupon is only for when you have more than 30 widgets in the cart "
Comment #8
rar commentedI've looked into this quite a bit more (7.x-2.0). The error messages are generated by
As part of the function
commerce_coupon_commerce_cart_order_refresh().Following the logic you get to
commerce_coupon_evaluate_conditionswhich calls drupal_alter which allows you to use
HOOK_commerce_coupon_condition_outcome_alter
Unfortunately there are a few issues which prevent being able to use HOOK_commerce_coupon_condition_outcome_alter
1.
$outcome = rules_invoke_component('coupon_type_' . $coupon_wrapper->type->value() . '_conditions', $coupon_wrapper, $order_wrapper, $data);always returns TRUE no matter what.2. commerce_coupon_commerce_cart_order_refresh gets called several times even if not actually adding the coupon. So .you can generate the static error message. Unfortunately if you add
$error = &drupal_static('commerce_coupon_error_' . strtolower($coupon->code));early, then other logic in the commerce_coupon module will cause adding of the coupon to fail with that error message even if the coupon should have been added.Ran into a wall and out of time to look into this more.