I have several times set up discount coupons with expiry dates, only to find that they do not expire; they are still active and available after the expiration date. I'm a novice at SQL, but I think part of the problem is at line 1112 in uc_discounts.module, there appears to be an extra "AND (%s)" in the select statement (iow, the line needs to be deleted); compare that query to the one just below.
However, this is not the full fix because the subsequent query is still bringing up expired coupons (and applying them). My guess is something going on with has_expiration.
Also, the explanatory description of the "Discount expires" checkbox reads "Whether or not this discount will be applied if other discounts are." -- this glitch is caused by line 564 in uc_discounts.admin.inc
For completeness, the coupons I am doing are combinable, weight 1, expires (with date), min quantity, amount 1, require code, single product to qualify, fixed amount off, discount amount, filter by products, product selected is the same as single product to qualify, apply once, 1 use per user.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | uc_discounts.patch | 838 bytes | davidburns |
Comments
Comment #1
MadOverlord commentedComment #2
MadOverlord commentedHad some time to do some more checking. The problem is actually that both of the queries around line 1112 are wrong. They both have missing "AND (%s)" clauses in them; each should have 4.
In other words, the selects should look like this:
...
AND (d.has_role_filter=0%s)
AND (%s)
AND (%s)
AND (%s)
AND (%s)
AND (d.has_expiration<>0 AND d.expiration<=%d)
...
Comment #3
mpotter commentedI can confirm that I had the same problem with discounts not expiring and the above fix in #2 also solved the problem for me. Thanks very much for posting this fix!
Comment #4
MadOverlord commentedLets hope it makes it into the next release!
R
Comment #5
Sohodojo Jim commentedI confirm that this query tweak fixed the non-expiry issue on our site. Good catch. This needs to find its way into the dev release ASAP as this is one of the very good features of this excellent module... and it should work as expected/needed.
Comment #6
redhatmatt commentedbump.
That worked for me, it should be 4 AND (%s) in 2 different places close to line 1112.
Comment #7
davidburnsLooks like this has been fixed in head. But for those of you still using the dev release (like myself) here's a patch rolled against it.
Comment #8
butler360 commentedThe patch seems to work. This should be committed to dev, as it can be a costly issue for a site maintainer.
Comment #9
sam_gigo commentedNote that the missing "AND (%s)" also stop the 'Filter by SKU' and 'Filter by Class' from working properly as those filters are never added to the sql statement
-------------------------------
http://www.dhmedia.com.au
Comment #10
davidburnsThis got rolled into dev in a larger commit.
http://drupal.org/cvs?commit=404310