Index: uc_coupon.module =================================================================== --- uc_coupon.module (revision 1186) +++ uc_coupon.module (working copy) @@ -710,6 +710,30 @@ } /** + * Coupon Per Product Validation Handler + * + * @param $code + * The coupon code + * + * @param $item_nid + * The product item node ID + * + * @return + * Boolean - Can this coupon be used with the given product. + */ +function uc_coupon_product_validate($code, $item_nid) { + $coupon = db_fetch_object(db_query("SELECT data FROM {uc_coupons} WHERE code = '%s' AND status ='1' AND valid_until > %d", $code, time())); + if ($coupon->data) { + $coupon->data = unserialize($coupon->data); + } + if (isset($coupon->data['products']) && (isset($coupon->data['negate_products']) ^ in_array($item_nid, $coupon->data['products']))) { + $result = uc_coupon_validate($code); + return $result->valid; + } + return FALSE; +} + +/** * Implementation of hook_checkout_pane(). * * Show a pane just above the order total that allows shoppers to enter a coupon