Hello,
I createt a new action which triggers at 'uc_checkout_complete'. As parameter it gets the whole $order.

What I want to do is calling another function within my action and pass the $order to it. The other function needs to change a value of order. But by doing this $order gets changed global and all other functions/hooks getting $order after my action will get the modified one. Here's the code:

/**
 * Implementation of hook_configuration().
 */
function my_module_ca_predicate() {
  $predicates['my_module_predicate'] = array(
    '#title' => t('Do something'),
    '#trigger' => 'uc_checkout_complete',
    '#class' => 'my_module',
    '#status' => 1,
    '#actions' => array(
      array(
        '#name' => 'my_module_action_my_action',
        '#title' => t('Do something.'),
        '#argument_map' => array(
          'order' => 'order',
        ),
      ),
    ),
    '#description' => t('This is some helptext.'),
  );

  return $predicates;
}

/**
 * Implementation of hook_action_info().
 */
function my_module_ca_action() {
  $actions['my_module_action_my_action'] = array(
    '#title' => t('Do something.'),
    '#callback' => 'my_module_action_my_action',
    '#arguments' => array(
      'order' => array('#entity' => 'uc_order', '#title' => t('Order')),
    ),
    '#category' => t('Order'),
  );
  return $actions;
}

function my_module_action_my_action($order, $settings) {
  dpm($order); // *
  foreach($order->products as $product) {
    my_module_decrement_product_stock($product, $order);
  }
  dpm($order); // **
}

function my_module_decrement_product_stock($product, $order) {
  $product->model = 'foobar'; // changes the value in $order->products[0]->model at **
  /* Even this will change the value for $order at ** !!
  $product_copy = $product;
  $product_copy->model = 'foobar';
  */
}

$order at ** differs from $order at *.
Please help! After my action 'uc_stock_decrement_product_stock()' is called and gets the $order variable with the changed model-numbers which is very bad since the stock gets decremented twice :(
What is going around here? I'm very confused. I hope anyone has an idea.

Greetz haggins