Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm in the testing process of deploying this module and I'm getting 2 certificates generated with each order. I'm running D6.14 U2.0 and GC1.1 any ideas?
See attached screenshot.
Comment | File | Size | Author |
---|---|---|---|
#3 | Screen shot 2009-12-22 at 1.36.18 PM.png | 38.75 KB | Clint Eagar |
screenshot.png | 48.27 KB | Clint Eagar |
Comments
Comment #1
torgosPizzaI noticed this too today. It seems that hook_order() is called twice, for some reason.
I've edited line 680 (found inside uc_gift_certificate_create_new_certs() which is called based on the status settings in the Store Settings page. Now it looks like this:
This helps us in two ways:
1) Now instead of looking for the attribute "Recipient's Email Address" we're looking to see if a Dollar Amount attribute is present, which is common for all certificates - at least, I think. This means we can sell physical Gift Card-type certificates that are printed in our office and mailed to the purchaser.
2) When hook_order is called twice, this new condition checks to make sure that a Certificate Code doesn't already exist (and only creates new certificates if it doesn't). This way, if the order data already has a Certificate Code, then it's not generated again.
The only potential issue I see with this fix, that I don't have time to investigate yet, is what if someone orders 2x certificates? One for one person, another for a second person? I had this working in my local copy of the 5.x module, I'll look through it and see if I can make a similar patch for the 6.x version.
Comment #2
torgosPizzaMarking this as duplicate of #543430: Gift Certificate module re-issues multiple certificates when order status is changed. - my solution is similar to the one proposed in a comment on that page, except I changed the Email address attribute to Dollar Amount. jrust, let me know if you think this is better, or if there's another solution that will work.
Comment #3
Clint Eagar CreditAttribution: Clint Eagar commentedJust tested the code change in post #1 and no certificate is generated, no email is sent, no code is generated.