With the new version of commerce coupon the validation of the submitted coupon code has changed.
The function commerce_coupon_code_is_valid() doesn't exist anymore. Instead, the coupon is redeemed with
commerce_coupon_redeem_coupon_code(). An error is returned if the code is not valid.

I changed the code as follows:
Validation stripped to check for empty form field

/**
 * Validate handler for commerce coupon redeem form.
 */
function commerce_coupon_redeem_form_validate($form, &$form_state) {
  // Get order from $form_state.
  $order = $form_state['order'];
  // Get coupon code from $form_state.
  $code = $form_state['values']['coupon_code'];
  // Check if coupon code is empty.
  // Validate the coupon code.
  if (empty($form_state['values']['coupon_code'])) {
    form_set_error('coupon_code', t('Your coupon code is required.'));
  }
}

The coupon is simply redeemed or the error returned.

/**
 * Submit handler for commerce coupon redeem form.
 */
function commerce_coupon_redeem_form_submit($form, &$form_state) {
  // Get order from $form_state.
  $order = $form_state['order'];
  // Get coupon code from $form_state.
  $code = $form_state['values']['coupon_code'];
  
  // Redeem coupon with current order.
  $error = '';
  commerce_coupon_redeem_coupon_code($code, $order, $error);
  if (empty($error)) drupal_set_message(t('Coupon code has been successfully redeemed.'));
  else drupal_set_message(t('Error: ').$error, 'error');
}

This solution works for me.

Comments

subetha_de created an issue. See original summary.

subetha_de’s picture

Issue summary: View changes
@purush’s picture

Assigned: Unassigned » @purush
Status: Active » Closed (fixed)

Thanks for finding the issue and for the quick solution.

I have updated the module code. Please check.

Thanks & Regards,
Thaman