Project:
Gift CertificateCategory:
bug reportPriority:
normalAssigned:
UnassignedStatus:
activeWhen ordering from my test store, I've put in a few orders that don't include gift certificates. When doing this, on the "Order Completed" page I get a Drupal message that says "Certificate NOT issued" For now, I've just went into the module and deleted the message, but I'm wondering if it's an issue with my setup.


Same issue...but worse!
I get this message whenever I place an order, even when it does include a gift certificate! So the certs are not being issued!
I edited line 671 which shows the message to show some debug info as follows:
drupal_set_message("NOT issuing certificates: arg2 $arg2 gc_status_array[arg2]: ".$gc_status_array[$arg2]." gc_status_array: ".print_r($gc_status_array));
The results are identical both when ordering a certificate and a regular product:
NOT issuing certificates: arg2 pending gc_status_array[arg2]: 0 gc_status_array: 1
Array ( [payment_received] => payment_received [pending] => 0 [processing] => 0 [paypal_pending] => 0 [completed] => 0 [canceled] => 0 [in_checkout] => 0 )
So with respect to the message popping up when gift certificates are ordered, my take on it is that $arg2 is correct ("pending"), but that the array should have a 1 value for the "pending" key, since that's what's actually just happened.
And with respect to the message popping up for regular product orders, I wonder if the function that this code is in (uc_gift_certificate_order) gets called for all orders as a matter of being a generic hook, in which case there should be a check in there to suppress this functionality when it's not a gift certificate. Indeed, if it does pass the "pending check" (which as I note in the above paragraph, it really should), then currently it will even try to issue a gift certificate -- bad news, since there is none.
I'm hoping the module authors can step in here with some words of wisdom.
Peace,
Shiraz
Add me to the list...
I'm getting the same error.
Drupal 5.3
Ubercart RC4
Gift Certificates 1.2
It even happens on random pages.
I get 4 errors (or rather, messages, since they're green) of: "NOT issuing certificates"
Also happens whenever I purchase a product (even if it has no gift certificates associated with it).
Any ideas?
Re: Add me to the list...
I will take a look and also will email Darron, the module author. I don't have this issue but I may have modified my version of the module.
If you discover anything in the meantime please post back.
hook_order()
The error is coming up from the gift module's implementation of uber cart's hook_order().
In particular, in the case $op == 'update', there is this code:
<?php
//perhaps only for certain order status values
$gc_status_array_default = array (
'payment_received' => 'payment_received',
'pending' => 0,
'processing' => 0,
'paypal_pending' => 0,
'completed' => 0,
'canceled' => 0,
'in_checkout' => 0,
);
$gc_status_array = variable_get('uc_gift_certificate_order_status', $gc_status_array_default);
if(!$gc_status_array[$arg2])
{
//drupal_set_message("NOT issuing certificates");
return;
}
drupal_set_message("Issuing certificates");
?>
(I commented out the drupal_set_message call;)
I print_r'ed the $gc_status_array and $arg2 once, and had the following results...
The $gc_status_array contained a key 'completed' with the value of 0, and the $arg2 variable was equal to 'completed'. So, the if-condition looked at $gc_status_array['completed'], and since it was set to 0, it was negated to TRUE, the message would have been set and the function returned.
Shouldn't be there some kind of check to actually see if there are gift certificates assigned to/with the current product? The way it is right now, the hook is being called (and that code ran; message set) every time an order goes through (when the gift certificates module is enabled). Intentional?
//edit
That comment at the top ("perhaps...") makes me think that the module developer saw a potential problem here
//edit2
.
Unrelated, but...
In the 'load' case just above, there are three calls of db_num_rows($query) - why not make just one call and store the value in a variable? Would save a bit of processing
Actually, I just noticed that the same exact thing is being done in a few other places, the uc_gift_certificate_update_cert_vals() function in particular.
Live error example
I just randomly came across this error on another site.
I was google'ing for some "ubercart gift certificates," and came across the example at http://drupalgroup.com/?q=node/2 . Figured I would see how it works over there
. Filled out the form, chose "cheque/money order" as the payment type and submitted the order. Got the "NOT issuing certificates" message. See attached screenshot
.
Re: Live error example
Yeah I'm not sure why it's getting called, I need to dig in a little more. Can you look at your account on that site and at least confirm that the certificates DID, in fact, make it into your account? They work fine on our site, and I haven't changed anything (except for that message output).
Re: Re: Live error example
I don't actually have an account on the site I posted.
I do, however, have an account on the server I'm working on
.
Where, exactly, should I be looking for the gift certificates "making" it into my account? I've been looking around a bit, but have found nothing.
I'm actually experiencing another problem - the emails to gift certificate recipients are not being sent. Chances are the gift certificates are not making it into the accounts. At any case, new accounts are not being created when gift certificates are bought for non-users. Definitely something wrong there...
I'm trying to trace where the email problem is occurring right now. I found three functions which call uc_gift_certificate_mail_cert_notice() - the function which is (I think) supposed to send out the email. I put a bunch of echo's and exit()'s in all three of them, and none got called... Guess the script is not even going that far...
Re: Re: Re: Live error example
Interesting - I'd like to know what their server setup is like. You should be able to go into /admin/store/gift_certificates and see what has been added, as well as seeing your Certificates total during checkout, if you have any.
Like I said, this works on a live site - we don't get millions of people buying certificates for each other, but it does work as it should, at least for us. I won't have time to look into it a bit later, but if you discover anything let me know.
Getting warmer...
Getting warmer...
I was back tracing (by hand - argh!) the three functions which have calls to uc_gift_certificate_mail_cert_notice() (the function which send the certificate notifications) and it looks like the first two of them (uc_gift_certificate_issue_form_submit() and uc_gift_certificate_add_form_submit()) are not being called at all - by other functions or via callbacks. At least in uc_gift_certificate.module. Am I missing something? Any chance these are being called by ubercart from core modules? Seems strange to me, since the functions look like they are for form processing... but if that was the case, there would be forms of the same name in the uc_gift_certificate.module...
Anyways, the third function to call uc_gift_certificate_mail_cert_notice() is where things get interesting. The function is uc_gift_certificate_create_new_certs(), and the only place it gets called is... drum roll... uc_gift_certificate_order() - the very place of our "NOT issuing certificates" message. The call takes place within the same 'update' case, but below the if(!$gc_status_array[$arg2]) condition which returns the function. Thus, the call never happens, the emails never get sent, and (presumably), the gift certificates do not actually get created.
Would be great if the module developer could shed some light on what's going on here
Re: Re: Re: Re: Live error example
I just checked /admin/store/gift_certificates on my server. It's empty, but I've "bought" about 20 gift certificates today (during testing/dev). So, they're not getting saved...
Re: Re: Re: Re: Re: Live error example
Can you look at two places:
Your Watchdog logs (/admin/logs/watchdog)
And the database itself?
Check the logs first to see if you have any SQL syntax errors, or missing table warnings, or anything like that. Then, check your database for a table called uc_gift_certificates. If the table isn't there, then the module might not have installed fully. If it is there, then it's probably a problem with the code. I'm trying to think of why those functions wouldn't be called - and offhand, I can't think of any reason.
I'll dig into the code today after I leave the office and see if I can't shed some light on what's going on.
Re: Re: Re: Re: Re: Re: Live error example
There are no PHP/MySQL errors and the table has been there all along (I've been periodically checking it - it's always been empty).
I commented out the following code from uc_gift_certificate_order():
<?php
/*
if(!$gc_status_array[$arg2])
{
drupal_set_message("NOT issuing certificates");
return;
}
drupal_set_message("Issuing certificates");
*/
?>
Have been testing it with the above comment, and everything seems to be working. Gift certificate recipients get the proper email, the uc_gift_certificates table gets the proper record, the user account gets created, the user is able to purchase goods (or in our case, subscriptions) using their gift-certificate money, etc. Everything seems to be working.
The question is, how critical is the above code and what will (may) happen because of the comment?
//edit
Correction, there is one PHP error in the watchdog:
uc_subscribe_renew_subscription called for an order product id (186) that already has a registered subscription (21).
The subscription module is being used to renew a user's purchased subscription.
Re: Re: Re: Re: Re: Re: Re: Live error example
That bit of code isn't that important. I think it's really just checking against what order statuses to update the gift certificate values. (Which... I'm not quite sure why the conditional is there to begin with). I will contact the developer and see if he can explain why this is necessary... especially that if something has changed and it's causing those following functions to not get triggered.
If the only thing not working at that point is the messages, that aren't needed anyway, then you should be fine as you are. I'll look into this, as I mentioned, and see if I can make a cleaned up version.
Re: Re: Re: Re: Re: Re: Re: Re: Live error example
Sounds good, thanks for the input!
Now I seem to be having another problem... When products (subscriptions) are bought using the money from a "Gift Certificate," the orders get stuck in "Processing"...
Purchasing the same order with a credit card works fine. I should probably make a new thread about this...
Re: Re: Re: Re: Re: Re: Re: Re: Re: Live error example
Yeah I haven't gotten into subscriptions. It doesn't seem to happen with all products though? Just subscriptions?
I'm not sure what makes a subscription product unique. Gift Certificate is another payment method, really - guess it could be something such as a Workflow_ng config? Perhaps one needs to be added?
Ryan - can you give any pointers here?
Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Live error example
The site only contains Subscriptions. Regular (Credit Card) subscriptions work fine. Buying the same Subscription with a Gift Card does not put the order through to "completed," but leaves it in "processing."
I do have a workflow-ng action setup on the event "A payment gets entered for an order" to check the order balance, and if it's >= 0 update the order status to "completed". I looked into adding another action for the gift purchases, but there are no related actions
.
Anyways, I'm heading home now and will hit this again tomorrow.
Thanks for your help!
//edit
Completely off-topic, but is there a way to change the username on this site? (like on Drupal.org)
"kerunt" is something I've been using informally for about ~8 years, and have recently been changing anything work-related to "yuriy@yuba"...