function uc_wishlist_view_form in UC Wish List 6
Same name and namespace in other branches
- 7 uc_wishlist.pages.inc \uc_wishlist_view_form()
Display a page allowing the customer to view his/her wish list.
1 string reference to 'uc_wishlist_view_form'
- uc_wishlist_display in ./
uc_wishlist.pages.inc - Display a wish list for viewing or altering.
File
- ./
uc_wishlist.pages.inc, line 238 - Page callback and functions for wish lists.
Code
function uc_wishlist_view_form($form_state, $items, $wid, $own) {
$form = array();
$form['items'] = array(
'#tree' => TRUE,
);
// Load each wish list product and add it to the form array.
foreach ($items as $item) {
$node = node_load($item->nid);
$element = array();
$element['nid'] = array(
'#type' => 'value',
'#value' => $node->nid,
);
$element['wpid'] = array(
'#type' => 'value',
'#value' => $item->wpid,
);
$element['module'] = array(
'#type' => 'value',
'#value' => 'uc_product',
);
if ($own) {
$element['remove'] = array(
'#type' => 'checkbox',
);
}
$item->haveqty = 0;
if (is_array($item->purchase)) {
$item->haveqty = count($item->purchase);
}
$element['title'] = array(
'#value' => l(filter_xss($node->title, array()), 'node/' . $node->nid),
);
$description = '';
foreach (module_implements('cart_item_description') as $module) {
$description .= module_invoke($module, 'cart_item_description', $item);
}
if ($description) {
$element['description'] = array(
'#value' => $description,
);
}
$element['#total'] = $item->price * $item->qty;
$element['data'] = array(
'#type' => 'hidden',
'#value' => serialize($item->data),
);
$element['wantqty'] = array(
'#type' => 'textfield',
'#default_value' => $item->qty,
'#size' => 5,
'#maxlength' => 6,
'#disabled' => $own ? FALSE : TRUE,
);
if (!$own) {
// Disabled elements do not pass their default value.
$element['wantqty']['#value'] = $item->qty;
}
$element['haveqty'] = array(
'#type' => 'textfield',
'#default_value' => $item->haveqty,
'#size' => 5,
'#maxlength' => 6,
'#disabled' => TRUE,
);
$element['qty'] = array(
'#type' => 'textfield',
'#default_value' => $item->qty - $item->haveqty > 0 ? $item->qty - $item->haveqty : 1,
'#size' => 5,
'#maxlength' => 6,
);
$element['addcart'] = array(
'#type' => 'submit',
'#name' => 'addcart-' . $item->wpid,
'#value' => t('Add to cart'),
);
$form['items'][] = $element;
}
$form['wid'] = array(
'#type' => 'hidden',
'#value' => $wid,
);
if ($own) {
$form['own'] = array(
'#type' => 'value',
'#value' => TRUE,
);
$form['update'] = array(
'#type' => 'submit',
'#value' => t('Update wish list'),
);
}
return $form;
}