Skip to content

Instantly share code, notes, and snippets.

@carwin
Created September 6, 2012 01:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carwin/3649371 to your computer and use it in GitHub Desktop.
Save carwin/3649371 to your computer and use it in GitHub Desktop.
Drupal 6: Use hook_form_alter() to remove the "Remove" button on Ubercart's cart form
<?php
function modulename_form_alter(&$form, $form_state, $form_id) {
switch ( $form_id ) {
case 'uc_cart_view_form':
/*
* This is how you can remove the "remove"
* button for each item.
*/
foreach($form['items'] as $k => $v ) {
if(is_integer($k) && isset($v['remove'])) {
unset($form['items'][$k]['remove']);
}
}
/*
* If you remove the "remove" button from the form
* you'll want to remove the table head (thead) cell text.
*/
foreach($form['items']['#columns'] as $k => $v) {
unset($form['items']['#columns'][$k]['cell']);
}
/*
* This is how you can remove the "remove" column entirely.
*/
unset($form['items']['#columns']['remove']);
unset($form['update']);
break;
default :
break;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment