The latest release of Ubercart had checkbox attributes. This (comprehensive) patch now allows the shop owner to select by default none, one, some or all of the available options. More or less the last part of integrating the checkbox attributes in Ubercart.
Still to do:
Testing! Works flawless (as far as I know) with normal products but didn't test for classes or product kits. Did however try to change the existing code so it should be working.
The table in the node/x/edit/attributes states the default attribute, but now merely N/A. Should be easily changed to show the default option(s), but since we have a new "label" there, space is getting a little cramped and it could be omitted altogether imho.
Changes:
This patch includes database changes and updates. The default options are dropped from the attribute tables and included in the option tables. Upgrade queries included.
Hope we can enjoy checkbox default options support in core soon!
Best regards
Mark
Comment | File | Size | Author |
---|---|---|---|
#9 | default_checkboxes_3.patch | 13.04 KB | Berdir |
#9 | default_checkboxes_fix_only.patch | 1.19 KB | Berdir |
#2 | default_checkboxes_2.patch | 12 KB | splash112 |
default_checkboxes.patch | 11.96 KB | splash112 | |
Comments
Comment #1
splash112 CreditAttribution: splash112 commentedComment #2
splash112 CreditAttribution: splash112 commentedForgot to check the new code with coder.
Please find a cleaned up version of the patch in the attachments.
Comment #3
Schoonzie CreditAttribution: Schoonzie commentedWill this be included in a future release of Ubercart (ie 6.x-2.3)?
I'm just wary of changing the database structure now if this won't make it into a future release.
Comment #4
splash112 CreditAttribution: splash112 commentedSo far: no
Comment #5
TR CreditAttribution: TR commentedIt sounds like a reasonable feature, but I need someone other than the original poster to actually install the patch and test it out in various circumstances then report back here before it can possibly be committed. So if this is something you're interested in, I encourage you to help out.
Comment #6
splash112 CreditAttribution: splash112 commentedHi TR,
Thanks for looking into it.
Testers please! Module will make database changes, but when rolled back, site will continue as before (deleting data is commented out).
While patching anyway, you might want to have a look at:
http://drupal.org/node/590918
Thanks
Mark
Comment #7
muddie CreditAttribution: muddie commentedI would love to get this working but I have a newer version of ubercart than the one this patches.
Any chance someone who knows how could update the patch?
Thanks.
Comment #8
cYu CreditAttribution: cYu commentedI'm subscribing because if this does go in, it will break some of the code in uc_aac which expects default_option to be a string and not an array.
Comment #9
BerdirI can confirm that this works as expected, attaching a slightly updated patch (removed some commented out stuff).
Note: Configuring default values for attribute type "checkboxes" is currently broken or to say more exactly, simply not implemented:
If the attribute type is checkboxes, the default value is always an empty array. It would also be possible to fix this *bug* by just changing that line, without breaking the schema and API and introducing new features. Downside is that it is only possible to define a single default value for checkboxes attributes, but that's already better than the current broken code.
There is an additional issue that when an attribute is required, the default option is removed. This is removed in the original patch too and I'm also removing that in the bugfix patch. Imho, it would be better if it would be possible to allow not selecting a default value.
Attaching the updated original patch (update function to remove fields still disabled) and the bugfix only patch.
Comment #10
SeanA CreditAttribution: SeanA commentedIf we're going to have attribute checboxes, there really needs to be a way to set them as checked or unchecked by default. Patch in #9 works properly for setting default values. Patch applies cleanly and works on Ubercart 2.4. Thanks!
Comment #11
evancooperman CreditAttribution: evancooperman commentedI also just applied the patch. Unfortunately, for those who already have many attributes created this patch will force a reinstallation of the uc_attribute module which will wipe out all your attributes - beware!
I will try to post the code to do the database migration so you don't actually have to uninstall/reinstall the module.
Thanks for the patch, other than the issue above it works great, thanks for doing this!
Comment #12
evancooperman CreditAttribution: evancooperman commentedOops, didn't run the update part of the install script, my mistake! If this is run all should be fine.
Comment #13
daamy CreditAttribution: daamy commentedThank you Berdir for the patch
Comment #14
anacronaut CreditAttribution: anacronaut commentedThanks for the patch Berdir (post #9)!
And thanks also for the tip, cYu (post #8). Patch works fine as long as uc_aac is not enabled.
Hope to see a patch for that soon.
Comment #15
TR CreditAttribution: TR commentedRestoring tags.
Comment #17
luis_san CreditAttribution: luis_san commented#2: default_checkboxes_2.patch queued for re-testing.
Comment #18
TR CreditAttribution: TR commentedI don't know what the point is of requesting a re-test. The patch in #9 failed two years ago and no-one has fixed it since, so there's absolutely no way that it is going to magically pass if you try the test again.
If you want to help get this feature implemented, you can re-work the patch to make it pass, to fix the problems raised in #11, and make it apply to the current version of Ubercart. You can and should do all your testing locally before you submit a new patch. Any new patch should also include new test cases - uc_attributes already has extensive test cases, and will need new test cases for the new features.
Comment #19
Alan D. CreditAttribution: Alan D. commentedConsidering the age, I think D7 is the best place to start again on this :(
After 10 or so "works as designed" related issues, it is nice to see this being considered :)
Comment #20
TR CreditAttribution: TR commentedThis is still a valid feature request, but unless someone puts in the work this is not going to be changed in D7 because of the data loss issue when changing the data model from a single valued default to an array default.
The intermediate step proposed in #9, to let checkbox attributes use a single valued default, can be done without impact. Perhaps another way to go is to use a bitmap rather than an array to set multi-valued defaults. That would not require a data model change and could be backwards compatible with a suitable update function.
Also not addressed here is the question of what to do if an attribute is changed from a checkbox with many default options to a select box where only one default is permitted.
Regardless, moving this to D8 as that is where new features should go at this point.
It will still require community participation to get this implemented.