+++ sites/all/modules/contrib/uc_coupon/uc_coupon.module	Wed Jul 22 09:22:06 2009
@@ -191,6 +191,8 @@
     $value = $coupon;
     $used = db_result(db_query("SELECT COUNT(*) FROM {uc_coupons_orders} WHERE cid = %d", $value->cid));
     $form['#uc_coupon_cid'] = $value->cid;
+    $form['#uc_coupon'] = $value;
+    $form['#uc_coupon_used'] = $used;
   }
   else {
     $value->valid_until = time();
@@ -214,7 +216,7 @@
     '#description' => t('Coupon codes cannot be changed once they have been used in an order.'),
     '#default_value' => $value->code,
     '#size' => 25,
-    '#required' => TRUE,
+    '#required' => !$used,
     '#maxlength' => 14,
     '#disabled' => $used,
   );
@@ -561,6 +563,11 @@
  * Coupon form validate handler.
  */
 function uc_coupon_add_form_validate($form, &$form_state) {
+  //The coupon was used and so the textfield disabled. The value was not submitted,
+  //so replace the value here.
+  if ($form['#uc_coupon_used']) {
+    $form_state['values']['code'] = $form['#uc_coupon']->code;
+  }
   // check to ensure a unique coupon code
   $name = db_result(db_query("SELECT name FROM {uc_coupons} WHERE code = '%s' AND cid <> %d", strtoupper($form_state['values']['code']), $form['#uc_coupon_cid']));
   if ($name) {
