I wanted to perform a quick alteration of ubercart form data (I want to remove links to product nodes in the shopping-cart). I found a solution that involves implementing hook_form_alter() by creating a new module (link and code below).
My question is, do I have to make a new module or can I just add this function into my theme's template.php file? I tried the later but I couldnt get it to work (I renamed the function to theNameOfMyTheme_form_alter).
(The bigger issue here is me trying to get my head round all this drupal 6 override stuff. Eg if I come across some code that I want to alter, how can you tell if you are supposed to create a module or change your theme?).
http://www.ubercart.org/forum/support/2298/remove_product_links_shopping_cart
function your_module_form_alter(&$form, &$form_state, $form_id) {
if($form_id == 'uc_cart_view_form') {
foreach($form['items'] as $key => $item) {
if(!empty($item['desc']['#value'])) {
$form['items'][$key]['desc']['#value'] = strip_tags($item['desc']['#value']);
}
}
}
}