No replies
peter170567's picture
Offline
Joined: 12/09/2013
Juice: -606
Was this information Helpful?

I would like to hook in some code (synchronize with an external databaseat the moment where an order is beeing placed and tried to use hook_uc_order. Where as the hook is called many times to several occasions, I never see the operation 'submit'.
Even a

<?php
die();
?>

does not have any effect. I would expect the site to halt, but I am able to place a complete order and see from the drupal_messages that the hook is called many times with different values for 'op'.

Here is my code:

<?php
function cmrshop_uc_order($op,$order,$arg2) {
   
drupal_set_message($op);
    switch (
$op) {
        case
'presave':
            foreach (
$order->products as $product) {
               
$product->qty = 1;
            }
           
// force quantities to 1 for all products in cart since we are dealing with unique, one of a kind products
           
break;
        case
'submit':
            die();
// !!!!
           
break;
    }
}
?>

Am I doing something wrong? Is there a better way to take action whenever an order is placed (and get a handle on the products included in the order)?
Does anybody successfully use hook_uc_order with 'submit' ?