Passing global variables to alter hooks The problem I have is that it seems that I can use global variable created inside another module, only if I use it inside callback function. I successfully tested it by inserting code inside existing modules.

The global variable is $subtotal.

function uc_checkout_pane_simple_quote($op, &amp;$arg1, $arg2) {
    global $subtotal; 
drupal_set_message($subtotal);


function uc_webform_pane_checkout_pane_callback($nid, $op, &amp;$arg1, $arg2) {
  global $subtotal; 
  drupal_set_message($subtotal);
}


In both cases the message shows the correct value.

However, inside other functions it is does not work.

function uc_webform_pane_checkout_pane_alter(&amp;$panes) {
  global $subtotal; 
  drupal_set_message($subtotal);
}

function uc_cartdetails_checkout_pane_alter(&amp;$panes) {
  global $user;
  global $subtotal; 
  drupal_set_message($subtotal);
}


What am I missing here?
What I am trrying to do: to show or hide checkout pane based on $subtotal value.

function uc_cartdetails_checkout_pane_alter(&amp;$panes) {
global $subtotal; 
  foreach ($panes as &amp;$pane) {

    if (($pane['id'] == 'webform_nid780') &amp;&amp; ((40 - $subtotal) &gt; 0) ) {
      $pane['enabled'] = FALSE;
      } 

    }
 }
The problem is not the global variable, but the fact you are using a function like drupal_set_message() inside a alter hook, which is not necessarily invoked when Drupal is outputting a page.
If you want to debug a hook, it's better you go with watchdog() and check in admin/reports/dblog if there is any message. You need to enable the Database Logging or the Syslog module to see any output; in the latter case, you will see the output on the syslog of your computer, instead of admin/reports/dblog.