2 replies [Last post]
VitaLife's picture
Offline
Bug Finder
Joined: 10/29/2007
Juice: 249
Was this information Helpful?

Sometimes the easiest things can be a pane in the butt. I have a simple request. How do I read data from the checkout pane so I can display it on the view pane. Here is my simple code.

<?php
function uc_checkout_pane_autoship($op, &$arg1, $arg2) {

    switch (

$op) {
        case
'view':
    
     
$contents['autoship'] = array(
             
'#type' => 'checkbox',
             
'#title' => t('Create an Autoship from this Order for next month.'),
             
'#weight' => 1,
           
'#default_value' => $checked,
             
'#required' => false,     
      );
   

      return array(

'contents' => $contents, 'next-button' => FALSE);
      break;

    case

'process':

       if (

$arg2['autoship'] ) drupal_set_message('Autoship was created for order '. $arg1->order_id);

    return

true;
     break;
    
     case
'review':
         
$review[] = array('title' => t('AutoShip'), 'data' => $arg2["autoship"]);
          return
$review;
        break;
    }
}
?>

Here is the issue, I can read the value of checkbox in 'process' but I cannot read the value of the checkbox in 'review'. I've tried storing the global var, but looks like review is done before process. I need to let the user know before checkout if they ahve the checkbox selected, I'm sure I'm missing something simple.
thanks
JimF

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Simple Checkout can be a pane

You should try using the $order->data array to store this data. The process $op actually happens before review, so you might adjust your code to look something like this...

<?php
 
case 'process':
   
$arg1->data['autoship'] = $arg2['autoship'];
    return
TRUE;

  case

'review':
   
$review[] = array('title' => t('AutoShip'), 'data' => $arg1->data['autoship'] ? t('Yes') : t('No'));
    return
$review;
?>
VitaLife's picture
Offline
Bug Finder
Joined: 10/29/2007
Juice: 249
Re: Re: Simple Checkout can be a pane

Worked perfect thanks, it's funny how someone can fix something in a minute that I spent 2 hours on Smiling