I start to use this module and in order to provide coupons for specific users in a within a certain period, means I'm using commerce_coupon_date and commerce_coupon_user.
Those module works really well and I really appreciate the discount integration in the 2.x version.

But my only regret is around error messages which doesn't provide enough details in my opinion.

For example, commerce_coupon_date doesn't provide any error message like "This coupon has expired" or "This coupon is not valid yet".
Another issue which looks like more a bug, sometime I try to apply an invalid coupon (I know it is invalid because of the date) to an order and the message "Coupon code applied" appear but the coupon is not applied.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

theo_’s picture

Here is a patch which provide better details in error messages for commerce_coupon_date.
User is now aware of the starting and ending date of the coupon in the error message.
New possible error messages:

  • Unfortunately the coupon is only valid from %start to %end
  • Unfortunately the coupon is only valid from %start
  • Unfortunately the coupon is only valid until %end

Line 8 to 9 fix the "Coupon code applied" message displayed even if the coupon wasn't applied.
Line 68 to 72 is just a way to ensure we don't walk into the first case each time.
I also moved the drupal_alter('commerce_coupon_redeem_error', $error, $coupon, $order); later in the function, so we really feel free to provide an error until the last moment.

dpolant’s picture

Status: Active » Needs review

I updated the modules to achieve this functionality although I changed your approach somewhat.

You bring up a good point about the error message alter hook. I'm going to leave it alone for now though because Commerce Giftcard uses this hook to check for a positive balance so any change to it will need to be coordinated.

Check out the latest dev to test these changes.

dpolant’s picture

Status: Needs review » Closed (fixed)