//create anew schedule pane at checkout
function uc_pizza_uc_checkout_pane() {
$panes[] = array(
'id' => 'schedule',
'callback' => 'uc_checkout_pane_schedule',
'title' => t('Pickup/Delivery Date & Time'),
'desc' => t("Show Pickup/Delivery Date & Time Pane"),
'weight' => 1,
'process' => TRUE,
'collapsible' => FALSE,
);
return $panes;
}
function uc_checkout_pane_schedule($op, $order, $form = NULL, &$form_state = NULL) {
require_once(drupal_get_path('module', 'uc_cart') . '/uc_cart_checkout_pane.inc');
switch($op) {
case 'view': //create a date-popup field and a separate field for time.
$format = 'Y-m-d';
if(isset($_REQUEST['panes']['schedule']['date']['date'])) {
$date = $_REQUEST['panes']['schedule']['date']['date'];
} else {
$date = date($format);
}
$descriptions = t("NOTE: You may schedule your pizza pickup or delivery below. The shop is only open from 5pm until 11pm, you may still place your order beyond store hours but it will be delivered the next working hour or your required schedule.");
$contents ['sched_date'] = array(
'#type' => 'date_popup',
'#title' => t('select a date'),
'#default_value' => $date,
'#date_format' => $format,
'#datepicker_options' => array('minDate' => 'today', 'maxDate' => variable_get("uc_pizza_max_days", '+6 days')),
'#date_label_position' => 'within',
'#date_increment' => 15,
'#date_year_range' => '-0:+0',
);
$base_hour= 5;
for($i=0; $i<25; $i++) {
$mins = str_pad((int) (($i % 4) * 15),2,"0",STR_PAD_LEFT);
$hour = str_pad((int) $base_hour,2,"0",STR_PAD_LEFT);
$options_time[$hour.$mins] = t($hour . ":" . $mins . " PM");
if($mins == 45) {
$base_hour++;
}
}
if(isset($_REQUEST['panes']['schedule']['time'])) {
$default_option = $_REQUEST['panes']['schedule']['time'];
} else {
$default_option = 0000;
}
$contents['sched_time'] = array(
'#type' => 'select',
'#title' => 'Time',
'#options' => $options_time,
'#default_value' => $default_option,
);
return array('description' => $descriptions, 'contents' => $contents);
break;
case 'prepare':
break;
case 'review': //**/THIS IS WHERE THE PROBLEM IS** please check process
dprint_r("order: ", $order); // only var with data
dprint_r("form: ", $form); //no data
dprint_r("form_state: ", $form_state); //no data
//$sched_date = $arg1->schedule_date;
//$sched_time = $arg1->schedule_time;
//$review[] = '<div class="giftwrap">' . t('You want @type as gift wrap medium', array('@type' => $gift_wrap_type)) . '</div>';
//$review[] = array('title' => t('Schedule'), 'data' => check_plain("$sched_date @ $sched_time"));
//return $review;
break;
case 'process':
//here in process i put the var to $order->schedule_date but unable to see it in $order at view
$order->schedule_date = $form_state['panes']['schedule']['sched_date']['#value']['date'];
$order->schedule_time = $form_state['panes']['schedule']['sched_time']['#value'];
return TRUE;
break;
case 'settings':
$max_days = variable_get("uc_pizza_max_days", '+6 days');
variable_set("uc_pizza_max_days", $max_days);
$contents['max_days'] = array(
'#type' => 'textfield',
'#title' => t('Calendar Max Days Limit'),
'#default_value' => $max_days,
'#maxlength' => 60,
'#size' => 32,
);
return $contents;
break;
}
}
我正在尝试添加一个窗格来检查ubercart的流程, $ op =查看和设置工作正常。
我在审核时遇到问题我尝试在$ op = process设置变量,但我无法在$ op = review
中找到它正在尝试此过程
$order->schedule_date = $form_state['panes']['schedule']['sched_date']['#value']['date'];
$order->schedule_time = $form_state['panes']['schedule']['sched_time']['#value'];
但是
在审核中似乎$ order-&gt; schedule_date和$ order-&gt; schedule_time不在$ order中;
任何人都可以帮助解决我所遗漏的问题......这是在D7
答案 0 :(得分:0)
使用$ order-&gt;数据,而不是尝试将自定义设置直接应用于$ order。 在“过程”
下试试这个case 'process':
// display arrays for devel testing
dpm($form);
dpm($order);
// use $order->data to store your submission data
$order->data['schedule_time'] = $form['panes']['schedule']['sched_time']['#value'];
break;
然后在“评论”下使用$ order获取您需要的数据。