I have Drupal 7 and UC 3 running with custom fields. I want to be able to display those fields in the shopping cart but can't seems to be able to do it. That's my first module creation attempt!
I try to use hook_form_alter(&$form, &$form_state, $form_id) {} in a custom module:
function swcart_form_alter(&$form, &$form_state, $form_id) {
switch($form_id) {
case 'uc_cart_view_form':
// Adding Grade column
$form['items']['#columns']['grade'] = array('cell' => 'Grade', 'weight' => 3.5);
for($i=0; $i < count($form['items']); $i++) {
if(isset($form['items'][$i]['nid'])) {
// Loading the node so we can retrieve the information we need.
$product = node_load($form['items'][$i]['nid']['#value']);
// Adding the 'Grade' to the product that is in the user's cart.
$form['items'][$i]['grade']['#value'] = $product -> field_product_term_data;
}
}
break;
}
}
The column 'Grade' shows up but no data in the table. What should I do? Do I have to modify the TAPir table? hook an other uc_cart function? Thanks