Ok, seeing as I've heard nothing from the developers on this, I decided to try and figure out what is going wrong.

The symptoms are: Coupons work fine with a direct payment method (such as COD), but do NOT get recorded in coupon_history with PayPal, and other payment methods, such as 3rd party Realex.

The problem is that the system for coupons has a pretty major design flaw.

the function getCoupon($code) is called to get the coupon and validate it.

It relies on being able to identify the customer related to the order by using $this->customer->getId(); This gets the user ID based on the currently logged-in user.

Unfortunately, any script that uses a callback function to validate an order through a payment gateway (eg PayPal, realex, etc) will not be logged in as the user as it is called by the payment gateway rather than by the customer. So, no customer id, and every coupon will be regarded as invalid.

So the coupon works as far as providing the discount, but fails at the point when it needs to be recorded in the database.

Solutions? I'll look at that next. At the callback stage we could simply get the coupon without worrying about whether it's valid or not. We've already applied the discount, all we need to do is log it.

So a second parameter to getCoupon() of $donotverify would be a reasonable solutuion. Will work on that next.

And here is a handy VQMod for those that would like it All credit to jolyonr for working out how to fix the problem, I just made it into a VQMod as I have to update lots of client websites with the same changes!

This is only tested in v1.5.1.3, but I would imagine it will work with any version > 1.5 as it is such a small amend.

Please post a reply to let other people know if it successfully works in other versions of OpenCart.

So I've been given instructions to run a coupon usage report for the last three months for company management, and when I go to the coupon history, there isn't any despite the fact that many customers have been successfully using our coupons with their purchases.

No history at all...

This is terribly disappointing. Has this issue been fixed in 1.5.4.X or not?

innuoluke wrote:And here is a handy VQMod for those that would like it All credit to jolyonr for working out how to fix the problem, I just made it into a VQMod as I have to update lots of client websites with the same changes!

This is only tested in v1.5.1.3, but I would imagine it will work with any version > 1.5 as it is such a small amend.

Please post a reply to let other people know if it successfully works in other versions of OpenCart.

Hi, I'm using 1.5.4. This VQMod doesn't work for me....I've tried manually changing the code as well. Still don't have any Coupon History and still have unlimited uses for coupon even though I've set the usage to 1 for each specific customer. My payment options are only COD and bank transfer. I can't figure out what I'm doing wrong. Can anyone help? Thank you.

nice to hear you guys blame opencart. actually i have found that problems are caused by not translating the order copon language file properly. check under catalog/language/total/coupon and make sure there is (%) in the translation for the total title.

the system parses the (%) to get the coupon code to add to the history.

Daniel wrote:nice to hear you guys blame opencart. actually i have found that problems are caused by not translating the order copon language file properly. check under catalog/language/total/coupon and make sure there is (%) in the translation for the total title.

the system parses the (%) to get the coupon code to add to the history.

Hi,
My language files have (%), and still doesn't have coupon history, nor does it limit coupon usage, even when set to one use per customer, one use per coupon.
Any help you can offer would be greatly appreciated. Thanks.

For anyone who has run into this bug and needs to correct historical orders placed en-mass the following SQL will do the trick. Be advised ,this is a VERY SLOW query, run at off-peak times and may require root database/system access if you are on shared hosting with a large database.

Designed for 1-off coupons, adjust appropriately if using table prefixes.

For Sale: Top URL's, including an OpenCart V-Pro Shop!
A wide range of matching Designs can be seen here: http://www.opencart.li
For Information on URL's offered, please contact me at: jti@jacob.chHundreds of Mods in 380+ Repositories for OC v.1.5.x - v.2.3.x
to be found on my Github Site: https://github.com/IP-CAM