I want to make a small modification to the ubercart cart page in my theme.

A typical item row on the cart page looks like this

[remove button] [product image] [product title] [quantity field] [row total]

All I want to do is move the [remove button] to the right hand side after [quantity field].

How can I do this?

1 Answer 1


You need to alter the default Ubercart's theming of the shopping cart form and increase the weight of "Remove" column so it is pushed to the end.
Add the following code to your theme's template.php file.

 * Themes the uc_cart_view_form().
function phptemplate_uc_cart_view_form($form) {

  // Increase the weight of Remove column, so it goes to the end.
  $form['items']['#columns']['remove']['weight'] = 100;

  // The rest of the code is default Ubercart's code you can see in:
  // theme_uc_cart_view_form() function in uc_cart.module.
  drupal_add_css(drupal_get_path('module', 'uc_cart') .'/uc_cart.css');

  $output = '<div class="uc-default-submit">';
  $output .= drupal_render($form['update']);
  $output .= '</div>';

  $output .= '<div id="cart-form-products">'
          . drupal_render($form['items']) .'</div>';

  foreach (element_children($form['items']) as $i) {
    foreach (array('title', 'options', 'remove', 'image', 'qty') as $column) {
      $form['items'][$i][$column]['#printed'] = TRUE;
    $form['items'][$i]['#printed'] = TRUE;

  // Add the continue shopping element and cart submit buttons.
  if (($type = variable_get('uc_continue_shopping_type', 'link')) != 'none') {
    // Render the continue shopping element into a variable.
    $cs_element = drupal_render($form['continue_shopping']);

    // Add the element with the appropriate markup based on the display type.
    if ($type == 'link') {
      $output .= '<div id="cart-form-buttons"><div id="continue-shopping-link">'
               . $cs_element .'</div>'. drupal_render($form) .'</div>';
    elseif ($type == 'button') {
      $output .= '<div id="cart-form-buttons"><div id="update-checkout-buttons">'
               . drupal_render($form) .'</div><div id="continue-shopping-button">'
               . $cs_element .'</div></div>';
  else {
    $output .= '<div id="cart-form-buttons">'. drupal_render($form) .'</div>';

  return $output;
  • Oh my god, thank you so much! Where did you learn this, did I miss an article or some documentation somewhere? Nov 5, 2013 at 22:39
  • You're welcome :) you just need to learn to find the corresponding source code and recognize what is it (a hook, form or something else) in order to alter it. In this case, you could do that by inspecting the table, grabbing some unique ID (e.g. cart-form-products) and searching the whole ubercart module folder for that string. It will come up with source function where you can see that you can override it with a phptemplate function in your theme. Hope this makes sense. Nov 6, 2013 at 9:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.