omg, a talking sausage.

Ubercart RC2 released and how to hide the Qty. field from cart

Share |

This post is not about the new Ubercart release but about hiding the Qty. field on the cart page. ;)
add this code to your new/old module to make the Qty. field go away.

<?php
function mymodule_form_alter(&$form, $form_state, $form_id) {
        if ($form_id == 'uc_cart_view_form') {
                //This line disables qty column
                unset($form['items']['#columns']['qty']);
                //This loop denies access to all qty fields for the form
                foreach($form['items'] as &$item)  {
                        if (is_array($item) & isset($item['qty'])) {
                                $item['qty']['#access'] = 0;
                        }
                }
        }
}
?>

See this issue for more info:
http://www.ubercart.org/forum/support/2483/hide_qty_field_cart

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre> <code> <img> <p> <br>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. The supported tag styles are: <foo>, [foo].

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.