Hook_Order Submit Bug?

Posts: 203
Joined: 09/06/2007

i do create a pdf file when order submit is called: But when I have anything in the cart that causes an tracking error meaning something else is out of stock, then the order submit is still called.

My point should we therefore not have a order submitted, when all is said and done with the order, that we then start off other things, the problem with save is it might be called too often.

case: submitted (one time execution)

Posts: 95
Joined: 10/29/2007
Bug Finder

I had a devil of a time getting this to work too, I think it would be good if there were a "op" that was called on successful completion of order. I needed to take order infomation over too our shipping and tracking system, and I needed to do it on order_subit, but after successful credit card charge, etc. Here is how I implemented it.

<?php
//hoook order
function shopping_order($op, $order, $status) // hoook_order for ubercart
{
if (
$op == 'update' && $status == 'pending' && uc_payment_balance($order) <= 1) {
// write the order to our database
}
?>

I had to play with this quite a bit for a few reasons. When submit it callled, you really don't know what happens during checkout. You see that I did uc_payment_balance($order) <= 1. I first had this set to uc_payment_balance($order) == 0, this makes sense, but I found out that due to rounding, I would often have .0013 left as a balance or something to that affect, (sometimes this was positive and sometimes negative, so I changed it to be < 1.

Another thing that may help you is to put something like this in hook order so you can watch all the events.

<?php
function shopping_order($op, $order, $status) // hoook_order for ubercart
{
drupal_set_message (
       
' OP:'. $op . '<br>' .
       
' state:'. uc_order_state_data($order->order_status, 'title') . '<br>' .
       
' status:'. uc_order_status_data($order->order_status, 'state') . '<br>' .
   
' order status:'. $order->order_status . '<br>' .
   
' function status:'. $status . '<br>' .
   
' balance:'. uc_payment_balance($order) . '<br>' .
'-------------------------------------------<br>'); 
}
?>

Now that we have workflow integration, would there be any way to setup a set of events that we could use in workflow to do certain things.... It would be cool if we could see.
order_complete
coupon_redeemed
order_abandoned
credit_card_declined
etc.

Thoughts...
Jim

Posts: 203
Joined: 09/06/2007

THX a lot!

So, i shall then send out my invoice pdf out once when the order is "update" and "pending"???

Posts: 203
Joined: 09/06/2007

my $order object is all but the orderid?

Posts: 5269
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Get the latest Ubercart...

Posts: 203
Joined: 09/06/2007

you mean a dev version for a client lifesite? Ok, where ... On the other hand what is so far passed along in 7e??? Cheers, uberman Eye-wink