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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

torgosPizza’s picture

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

if ($data && $data['attributes'] && isset($data['attributes']["Dollar Amount"][0]) && !isset($data['attributes']["Certificate Code"][0])){

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.

torgosPizza’s picture

Status: Active » Closed (duplicate)

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

Clint Eagar’s picture

Just tested the code change in post #1 and no certificate is generated, no email is sent, no code is generated.