diff --git a/uc_attribute/uc_attribute.admin.inc b/uc_attribute/uc_attribute.admin.inc index cf9b11b..22a1c67 100644 --- a/uc_attribute/uc_attribute.admin.inc +++ b/uc_attribute/uc_attribute.admin.inc @@ -95,11 +95,11 @@ function uc_attribute_form($form_state, $attribute = NULL) { '#default_value' => $label, ); $form['description'] = array( - '#type' => 'textfield', + '#type' => 'textarea', + '#rows' => '3', '#title' => t('Help text'), '#description' => t('Optional. Enter the help text that will display beneath the attribute on product add to cart forms.'), '#default_value' => isset($attribute->description) ? $attribute->description : '', - '#maxlength' => 255, ); $form['required'] = array( '#type' => 'checkbox', diff --git a/uc_attribute/uc_attribute.module b/uc_attribute/uc_attribute.module index 902277f..0296e9b 100644 --- a/uc_attribute/uc_attribute.module +++ b/uc_attribute/uc_attribute.module @@ -409,7 +409,7 @@ function uc_attribute_uc_product_models($node) { */ function uc_attribute_add_to_cart_data($form_values) { if (isset($form_values['attributes'])) { - return array('attributes' => $form_values['attributes']); + return array('attributes' => preg_replace('/\r\n/', "\n", $form_values['attributes'])); } else { return array('attributes' => array()); @@ -1104,7 +1104,7 @@ function _uc_cart_product_get_options($item) { $attribute = $node->attributes[$aid]; $name = _uc_attribute_get_name($attribute); // Only discrete options can affect the price of an item. - if ($attribute->display && count($attribute->options)) { + if (in_array($attribute->display, array(1, 2, 3)) && count($attribute->options)) { // There may be many selected options, or just one. foreach ((array)$selected as $oid) { if ($oid > 0) { @@ -1115,7 +1115,7 @@ function _uc_cart_product_get_options($item) { } } else { - // Handle textfield attributes. + // Handle textfield and textarea attributes. $options[$index] = array( 'attribute' => $name, 'aid' => $aid, @@ -1194,7 +1194,7 @@ function _uc_attribute_alter_form($product) { $options[$option->oid] .= $display_price; } - if (count($attribute->options) && $attribute->display > 0) { + if (count($attribute->options) && in_array($attribute->display, array(1, 2, 3))) { if ($attribute->required) { if ($attribute->display == 1) { $options = array('' => t('Please select')) + $options; @@ -1222,7 +1222,7 @@ function _uc_attribute_alter_form($product) { } else { $form_attributes[$attribute->aid] = array( - '#type' => 'textfield', + '#type' => $attribute->display == 0 ? 'textfield' : 'textarea', '#description' => check_markup($attribute->description), '#default_value' => '', '#required' => $attribute->required, @@ -1248,6 +1248,7 @@ function _uc_attribute_alter_form($product) { function _uc_attribute_display_types() { return array( 0 => t('Text field'), + 4 => t('Text area (multiple rows)'), 1 => t('Select box'), 2 => t('Radio buttons'), 3 => t('Checkboxes'), @@ -1263,7 +1264,7 @@ function _uc_attribute_display_types() { * Array of attribute ids that have price affecting options. */ function uc_attribute_priced_attributes($nid) { - $attributes = db_query("SELECT DISTINCT (pa.aid) FROM {uc_product_attributes} AS pa INNER JOIN {uc_attribute_options} AS ao ON ao.aid = pa.aid INNER JOIN {uc_product_options} AS po ON (po.oid = ao.oid AND po.nid = pa.nid) WHERE pa.nid = %d AND po.price <> 0 AND pa.display <> 0", $nid); + $attributes = db_query("SELECT DISTINCT (pa.aid) FROM {uc_product_attributes} AS pa INNER JOIN {uc_attribute_options} AS ao ON ao.aid = pa.aid INNER JOIN {uc_product_options} AS po ON (po.oid = ao.oid AND po.nid = pa.nid) WHERE pa.nid = %d AND po.price <> 0 AND pa.display IN (1,2,3)", $nid); $aids = array(); while ($attribute = db_fetch_array($attributes)) { $aids[] = $attribute['aid'];