Added "Links" display type for options in uc_attribute

Contrib type: 
Code/CSS Snippet
Status: 
Uploaded for testing
Moderation: 
Awaiting moderation

Downloads

Compatibility: 
Ubercart 2.x

Here is main diff for uc_attribute.module :

770a771,793
> case 4:
> $attr_type = 'link';
> break;
> }
>
> if ($attr_type == 'link') {
> $attr_links=array();
> foreach ( $attribute->options as $attr_option ) {
> $attr_links[]= l($options[$attr_option->oid],"cart/add/p".$nid."_q1_a".$attribute->aid."o".$attr_option->oid);
> }
> $form_attributes[$attribute->aid] = array(
> '#type' => "markup",
> '#value' => implode('',$attr_links),
> );
> }
> else {
> $form_attributes[$attribute->aid] = array(
> '#type' => $attr_type,
> '#description' => check_markup($attribute->description),
> '#default_value' => ($attr_type == "checkboxes" ? array() : $attribute->default_option),
> '#options' => $options,
> '#required' => $attribute->required,
> );
772,778d794
< $form_attributes[$attribute->aid] = array(
< '#type' => $attr_type,
< '#description' => check_markup($attribute->description),
< '#default_value' => ($attr_type == "checkboxes" ? array() : $attribute->default_option),
< '#options' => $options,
< '#required' => $attribute->required,
< );
807a824
> 4 => t('Links'),

And not sure if this changes are needed:

uc_attribute.module

88c88
< 'page arguments' => array('uc_attribute_form', 3),
---
> 'page arguments' => array('uc_attribute_form', 4),
95c95
< 'page arguments' => array('uc_attribute_delete_confirm', 3),
---
> 'page arguments' => array('uc_attribute_delete_confirm', 4),
103c103
< 'page arguments' => array('uc_attribute_options_form', 3),
---
> 'page arguments' => array('uc_attribute_options_form', 4),
117c117
< 'page arguments' => array('uc_attribute_option_form', 3, NULL),
---
> 'page arguments' => array('uc_attribute_option_form', 4, NULL),
126c126
< 'page arguments' => array('uc_attribute_option_form', 3, 5),
---
> 'page arguments' => array('uc_attribute_option_form', 4, 5),
134c134
< 'page arguments' => array('uc_attribute_option_delete_confirm', 3, 5),
---
> 'page arguments' => array('uc_attribute_option_delete_confirm', 4, 5),

uc_attribute.admin.inc

1045c1045
< $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);
---
> $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 <> 4 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);


PreviewAttachmentSize
uc_attribute_with_links_options.tar.gz28.25 KB