D
D
Dmitry2016-07-31 22:44:12
Drupal
Dmitry, 2016-07-31 22:44:12

How to add two span elements to the quantity field in Ubercart 2 (Drupal 6) add to cart form?

There is a standard form for adding goods to the cart. In the module in the ubercart/uc_pruduct/uc_product.module file, it is written like this

function uc_product_add_to_cart_form($form_state, $node) {
  $form = array();
  $form['#validate'][] = 'uc_product_add_to_cart_form_validate';
  $form['#submit'][] = 'uc_product_add_to_cart_form_submit';
  $form['nid'] = array('#type' => 'value', '#value' => $node->nid);
  if ($node->default_qty > 0 && variable_get('uc_product_add_to_cart_qty', FALSE)) {
    $form['qty'] = array(
      '#type' => 'uc_quantity',
      '#title' => t('Quantity'),
      '#default_value' => $node->default_qty,
    );
  }
  else {
    $form['qty'] = array('#type' => 'hidden', '#value' => $node->default_qty ? $node->default_qty : 1);
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' =>  variable_get('uc_product_add_to_cart_text', t('Add to cart')),
    '#id' => 'edit-submit-'. $node->nid,
    '#attributes' => array(
      'class' => 'node-add-to-cart',
    ),
  );
  $form['node'] = array(
    '#type' => 'value',
    '#value' => $node,
  );
  uc_form_alter($form, $form_state, __FUNCTION__);
  return $form;
}

Please tell me how this form hook should look like in template.php so that I end up with span elements with a certain class on both sides of the "quantity" field. To make it look like this.
<span class="pic-1"></span>
<input type="text" class="form-text required" value="1" size="5" name="qty">
<span class="pic-2"></span>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question