Originally, the module was written only to handle "Select box" type attributes, because that was the only requirement at the time. In order for the module to be considered "complete", it must be able to handle all 4 types of built-in Ubercart attributes.

Attribute types:

  • Text field
  • Select box
  • Radio buttons
  • Checkboxes

At first glance, I think there are two things to do to make this possible:

  1. Display attributes of all types in the "Add Attribute" dropdown list. Currently the query that selects attributes to display has a "WHERE display=1" condition in it to limit the list of attributes to "Select box" types.
  2. Display all selected checkbox options in the order edit page. The module assumes that only one option will be selected per attribute, so only the first option is displayed in the list of attribute in the order's product list. This is fine for "Text field," "Select box," and "Radio buttons" attribute types, because they can only have one option. But "Checkboxes" attributes can have multiple options, so the product list needs to be able to display all of them.
  3. Condense checkbox options into one string for editing. Added from comment #1 below.

Comments

m.stenta’s picture

Category: feature » bug

More considerations for checkboxes:

Checkbox attributes are the only attributes that can have multiple values. So aside from the display of them mentioned in item #2 above, we'll also have to figure out how to deal with them in the "Edit Attributes" form (in the popup).

This module currently just provides a textfield for editing the value of an option, so naturally it assumes that there is only one option selected, and will therefore only display the first option it finds in the textfield. When the attributes are saved, it saves the contents of the textfield to the [0] (first) item of the attributes array, and would discard any others.

So essentially, this module is broken when dealing with "Checkboxes" attributes. It will only display the first selected option in the textfield for editing, and will discard all other selection options from that attribute when you click "Apply."

I think that means this issue should be a "bug report" rather than a "feature request".

One possible solution to this, to keep things simple, would be to add a bit of logic to the form so that it loads all options into a single string, separated by commas, and put that into the textfield. Then, when the attributes are saved, the options wouldn't be lost, they would just be condensed into one option (essentially making them into a "Text field" attribute rather than "Checkboxes"). This would work for shops that don't need to maintain the separation of options, and only need the text.

I'm open to ideas on this. We're working on adding the ability to display Ubercart's default attribute form for each attribute (see #1375680: Replace arbitrary text fields with Ubercart attribute widgets), which would be a solution to this in most cases. However, I want to keep the ability to arbitrarily edit attribute/option titles, so this needs to be addressed in this context as well.

m.stenta’s picture

Attached is a patch which does all 3 of the things described in the summary.

m.stenta’s picture

Status: Active » Needs review
mattcasey’s picture

Ah, good catch. I think once you save something with the admin textfield, it should be assumed you're not planning on using the Ubercart field anymore. So long as the attribute title is retained, the UC field with checkboxes can still display but the options would need to be selected again. I think that would be a rare case.

Thanks for breaking up my patch, I will test.

scotwith1t’s picture

It still feels really unnatural having the auto-complete box when you're editing these fields. If you've got pre-defined attributes, using a specific widget and potentially only a few of the possible options for that attribute enabled for that product, i would think it would make perfect sense to go ahead and present the user with the widget as it would be in the product itself...that is to say, if it's a dropdown, show me a dropdown and only with the options for that attribute that are active for this product. If you don't have it enabled, it shouldn't be an option when editing.

Here's where my client is coming from: Imagine a large event where a couple dozen volunteers are registering people at the door...they have already ordered their t-shirt for the event, but you ran out of Smalls. There ARE no X-Smalls for this event, but you've asked the check-in volunteers to edit the order to reflect the size they are to receive from the t-shirt area and in order to better track what's needed for next year's event. They edit the attribute to read x-small, the participant goes over to the -shirt area to get theirs, the order shows an x-small shirt and there aren't any available...

I know this is very specific to this example, but see where I'm going with this? If it's not an option in the purchasing process, it shouldn't be able to be changed to that and certainly not to something that's not even an established option - XXX-Large shirts? um, no we didn't order any that big for this yoga event's participants ;) If you present a text field, that's too easy of a mistake to make and invalid if you've only got certain products available...

m.stenta’s picture

I believe what you're describing is a part of the patch in #1375680: Replace arbitrary text fields with Ubercart attribute widgets. This issue is just to fix a few bugs with "checkbox" attributes, mainly. It doesn't change anything in the interface, it just fixes some things that weren't working in the background.

The changes made in this patch are necessary for the latest changes in #1375680: Replace arbitrary text fields with Ubercart attribute widgets.

If you want to test this one, try adding some checkbox attributes to products, and make sure they work. Or, if you just want the stuff from the other issue, apply this patch, and then apply the other one, and you should be good to go.

scotwith1t’s picture

Sorry, going back and forth between this and the original issue now :) See my latest at #1375680: Replace arbitrary text fields with Ubercart attribute widgets and see if that makes sense to you? If this one would just be a more or less final patch for the 1.x version and the other is more like working towards a 2.x version, that's totally cool by me.

scotwith1t’s picture

Status: Needs review » Reviewed & tested by the community

Definitely seeing the other types of attributes here now, so I say this one works and can be committed.

m.stenta’s picture

Status: Reviewed & tested by the community » Closed (fixed)

Cool cool. I'm feeling pretty confident about this patch. It's not too complicated. I'm going to go ahead and commit it.

If any issues are discovered, please reopen.

m.stenta’s picture

Issue summary: View changes

Updated issue summary.