=== modified file 'uc_attribute/uc_attribute.admin.inc' --- uc_attribute/uc_attribute.admin.inc 2009-05-07 20:47:38 +0000 +++ uc_attribute/uc_attribute.admin.inc 2009-05-15 14:50:28 +0000 @@ -948,7 +948,7 @@ $query_from = " FROM"; $query_where = " WHERE"; $query_order = " ORDER BY"; - $result = db_query("SELECT pa.nid, pa.aid, pa.ordering, a.name, a.ordering, ao.aid, COUNT(po.oid) FROM {uc_product_attributes} AS pa LEFT JOIN {uc_attributes} AS a ON pa.aid = a.aid LEFT JOIN {uc_attribute_options} AS ao ON a.aid = ao.aid LEFT JOIN {uc_product_options} AS po ON ao.oid = po.oid AND po.nid = %d WHERE pa.nid = %d GROUP BY ao.aid, pa.aid, a.name, pa.ordering, a.ordering, pa.nid HAVING count(po.oid) > 0 ORDER BY pa.ordering, a.ordering", $nid, $nid); + $result = db_query("SELECT pa.nid, pa.aid, pa.ordering, pa.display, a.name, a.ordering, ao.aid, COUNT(po.oid) FROM {uc_product_attributes} AS pa LEFT JOIN {uc_attributes} AS a ON pa.aid = a.aid LEFT JOIN {uc_attribute_options} AS ao ON a.aid = ao.aid LEFT JOIN {uc_product_options} AS po ON ao.oid = po.oid AND po.nid = %d WHERE pa.nid = %d AND pa.display <> 3 GROUP BY ao.aid, pa.aid, a.name, pa.ordering, a.ordering, pa.nid HAVING count(po.oid) > 0 ORDER BY pa.ordering, a.ordering", $nid, $nid); $i = 1; $attribute_names = ''; $full_attributes = array(); === modified file 'uc_attribute/uc_attribute.module' --- uc_attribute/uc_attribute.module 2009-05-07 20:12:13 +0000 +++ uc_attribute/uc_attribute.module 2009-05-15 13:51:59 +0000 @@ -386,7 +386,7 @@ $attributes = array(); $options = _uc_cart_product_get_options($product); foreach ($options as $aid => $option) { - $attributes[$option['attribute']] = $option['name']; + $attributes[$option['attribute']][] = $option['name']; } $product->data['attributes'] = $attributes; } @@ -435,7 +435,12 @@ function uc_attribute_cart_item_description($item) { $rows = array(); foreach (_uc_cart_product_get_options($item) as $option) { - $rows[] = t('@attribute: @option', array('@attribute' => $option['attribute'], '@option' => $option['name'])); + if (!isset($rows[$option['aid']])) { + $rows[$option['aid']] = t('@attribute: @option', array('@attribute' => $option['attribute'], '@option' => $option['name'])); + } + else { + $rows[$option['aid']] .= t(', @option', array('@option' => $option['name'])); + } } if (count($rows)) { @@ -546,24 +551,33 @@ $data = $item->data; $node = node_load($item->nid); + $index = 0; if (!empty($data['attributes']) && is_array($data['attributes'])) { - foreach ($data['attributes'] as $aid => $oid) { + foreach ($data['attributes'] as $aid => $selected) { $attribute = $node->attributes[$aid]; // Only discrete options can affect the price of an item. if ($attribute->display && count($attribute->options)) { - $options[$aid] = (array)$attribute->options[$oid]; - $options[$aid]['attribute'] = _uc_attribute_get_name($attribute); + // There may be many selected options, or just one. + foreach ((array)$selected as $oid) { + if ($oid > 0) { + $options[$index] = (array)$attribute->options[$oid]; + $options[$index]['attribute'] = _uc_attribute_get_name($attribute); + $index++; + } + } } else { - $options[$aid] = array( + // Handle textfield attributes. + $options[$index] = array( 'attribute' => _uc_attribute_get_name($attribute), 'oid' => 0, - 'name' => $oid, + 'name' => $selected, 'cost' => 0, 'price' => 0, 'weight' => 0, ); } + $index++; } } else { @@ -647,10 +661,21 @@ } unset($attribute->default_option); } + switch ($attribute->display) { + case 1: + $attr_type = 'select'; + break; + case 2: + $attr_type = 'radios'; + break; + case 3: + $attr_type = 'checkboxes'; + break; + } $form_attributes[$attribute->aid] = array( - '#type' => $attribute->display == 1 ? 'select' : 'radios', + '#type' => $attr_type, '#description' => check_markup($attribute->description), - '#default_value' => $attribute->default_option, + '#default_value' => ($attr_type == "checkboxes" ? array() : $attribute->default_option), '#options' => $options, '#required' => $attribute->required, ); @@ -680,6 +705,7 @@ 0 => t('Text field'), 1 => t('Select box'), 2 => t('Radio buttons'), + 3 => t('Checkboxes'), ); } === modified file 'uc_order/uc_order.order_pane.inc' --- uc_order/uc_order.order_pane.inc 2009-05-06 18:27:07 +0000 +++ uc_order/uc_order.order_pane.inc 2009-05-15 13:48:35 +0000 @@ -756,7 +756,7 @@ $option_rows = array(); if (module_exists('uc_attribute') && is_array($options)) { foreach ($options as $attribute => $option) { - $option_rows[] = t('@attribute: @option', array('@attribute' => $attribute, '@option' => $option)); + $option_rows[] = t('@attribute: @options', array('@attribute' => $attribute, '@options' => implode(', ', (array)$option))); } } $data['product'] = array( @@ -872,7 +872,7 @@ $option_rows = array(); if (module_exists('uc_attribute') && is_array($options)) { foreach ($options as $attribute => $option) { - $option_rows[] = t('@attribute: @option', array('@attribute' => $attribute, '@option' => $option)); + $option_rows[] = t('@attribute: @options', array('@attribute' => $attribute, '@options' => implode(', ', (array)$option))); } } $data['product'] = array(