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.

CommentFileSizeAuthor
#7 uc_discounts.patch838 bytesdavidburns

Comments

MadOverlord’s picture

Title: Coupons do not expire properly - possible fix » Coupons do not expire properly
MadOverlord’s picture

Title: Coupons do not expire properly » Coupons do not expire properly - POSSIBLE FIX

Had 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)
...

mpotter’s picture

I 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!

MadOverlord’s picture

Lets hope it makes it into the next release!

R

Sohodojo Jim’s picture

I 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.

redhatmatt’s picture

bump.

That worked for me, it should be 4 AND (%s) in 2 different places close to line 1112.

davidburns’s picture

StatusFileSize
new838 bytes

Looks 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.

butler360’s picture

The patch seems to work. This should be committed to dev, as it can be a costly issue for a site maintainer.

sam_gigo’s picture

Note 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

davidburns’s picture

Status: Active » Fixed

This got rolled into dev in a larger commit.
http://drupal.org/cvs?commit=404310

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.