17 replies [Last post]
BigMike's picture
Offline
Joined: 10/20/2008
Juice: 1057
Was this information Helpful?

Hello UC,

At the Attributes > Options page (/node/###/edit/options), we have...

Use the checkboxes to enable options for attributes and the radio buttons to specify defaults for the enabled options. Use the other fields to override the default settings for each option. Attributes with no enabled options will be displayed as text fields.

...with the following columns: Attribute, Options, Default, Cost, Price, Weight, Order.

My request: Can we PLEASE have an option to Deselect all the check boxes?

I have an Attribute that has 38 options at the moment (with more to be added soon). Each time I add this attribute to a product in which only 3 attribute options exist, I have to manually uncheck / deselect 35 check boxes one-by-one which is ANNOYING and entirely CUMBERSOME!

Can we just have a simple option to deselect every option for any given attribute please? It seems so trivial, I really find it hard to believe this option is NOT available!

Thanks
Mike

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: "Select All" "Deselect All" for Attribute Options page, plea

So... this used to be the default behavior, and then it was reversed per a feature request on drupal.org. Sticking out tongue

Irony aside, perhaps these checkboxes could benefit from the Shift + click functionality that works elsewhere in Drupal. I like the idea... not sure what it will take to implement it on that form.

BigMike's picture
Offline
Joined: 10/20/2008
Juice: 1057
BigMike wrote:I have an
BigMike wrote:

I have an Attribute that has 38 options...

Ok, I think I've discovered a bug. I now have 43 options for this attribute in question, and when I uncheck the checkboxes except for a few that I need, and then click "Submit", the page reloads and all of the options are checked again, the default option have been moved to its default location, and the price modifications I just made are all reset back to zero.

Now, when I remove 4 options and have 39 options, it works ok. I didn't check at 40 or 41, but I am assuming the attributes have a limit of 40 options, and because it is not clearly documented that attributes can have no more than 39, I consider this a bug.

Can someone take a look into this please?

Thank you for your time
Mike

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: BigMike wrote:I have an

I just did some tests with 50 options, and I didn't see any problems. The only thing that happens that you might not expect is that the price changes get erased when an option is disabled. But that doesn't matter since it was still unchecked.

Are you on the latest version of Ubercart? There hasn't been many changes on these pages for the past couple of versions.

As a side note, I have figured out how to put the disabled options on the bottom, because that just makes more sense. Expect this in a later version.

BigMike's picture
Offline
Joined: 10/20/2008
Juice: 1057
Re: Re: BigMike wrote:I have an

Ok, I just spent some more time with this..

I created a new attribute and gave it 41 options. Added it to a product and teadiously unchecked 38 options leaving 3 options checked, gave them some random prices, selected one as the default, and submitted.

To my surprise, it worked!

Then I went back, removed this new attribute, and added the same attribute that gave me trouble above, did the same process, and after submitting it, again, it worked!

I don't know what was going on last night, but that is crazy that is is working now ? ! ?

Sorry for the false alarm!

Mike

fang27's picture
Offline
Joined: 01/30/2008
Juice: 121
I'm having this issue,

I'm having this issue, though: all options are selected, and it is really time-consuming to have to deselect dozens of options. Any solution or patch for this?

fang27's picture
Offline
Joined: 01/30/2008
Juice: 121
Hack Around

When you don't like it, hack around it.

Open up this file:

modules/ubercart/uc_attribute/uc_attribute.module

And go to lines 873-875 (considering you haven't changed anything in this file before). Comment out those lines, which are, BTW:

foreach ($attribute->options as $option) {
db_query("INSERT INTO $opt_table ($id, oid, cost, price, weight, ordering) VALUES ($sql_type, %d, %f, %f, %f, %d)", $form_values['id'], $option->oid, $option->cost, $option->price, $option->weight, $option->ordering);
}

That will leave everything unchecked when an attribute is first added. From there, check off the attributes you want. Don't forget a default attribute is required.

BigMike's picture
Offline
Joined: 10/20/2008
Juice: 1057
Re: Hack Around

Thanks fang27, I just now logged in and manually searched for this thread and found your reply above. Wish I had seen this over a month ago. Ho hum.

Although I dislike having to keep a list of what files I've modified so I can preserve modifications/hacks when upgrading to future releases, I have performed your suggesting and am glad to have this feature disabled!

Thank you very much for your help and have a nice day,
BigMike

fehin's picture
Offline
Joined: 12/17/2008
Juice: 151
Re: Hack Around

This worked for me. Thanks.

Digital Fairy's picture
Offline
Joined: 10/05/2009
Juice: 23
On version 6.x-2.0-rc3

Go to file uc_attribute.admin.inc, and comment out lines 673-675

foreach ($attribute->options as $option) {
db_query("INSERT INTO $opt_table ($id, oid, cost, price, weight, ordering) VALUES ($sql_type, %d, %f, %f, %f, %d)", $form_state['values']['id'], $option->oid, $option->cost, $option->price, $option->weight, $option->ordering);
}

Bye.

Digital Fairy

Digital Fairy
Digital Advertising & Media Agency
www.digitalfairy.it

cYu
cYu's picture
Offline
Bug FinderGetting busy with the Ubercode.
Joined: 11/19/2007
Juice: 850
Re: I'm having this issue,

If you have firefox you might want to check out Checkfox, https://addons.mozilla.org/en-US/firefox/addon/2393

Drupal in general can get crazy with checkboxes, so I've found that being able to just do a "Select All" on an entire page and then right click to either check or uncheck everything select is a big time saver.

willdashwood@drupal.org's picture
Offline
Joined: 10/01/2008
Juice: 15
BigMike wrote:Ok, I think
BigMike wrote:

Ok, I think I've discovered a bug. I now have 43 options for this attribute in question, and when I uncheck the checkboxes except for a few that I need, and then click "Submit", the page reloads and all of the options are checked again, the default option have been moved to its default location, and the price modifications I just made are all reset back to zero.

You may be having the same issue I had here, solution here.

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4110
Re: BigMike wrote:Ok, I think

Just out of curiosity, what are you guys selling that you need more than 40 options? Smiling I can't imagine what that form would look like. Although I guess if it were something like a Web Hosting company, that would make sense...

--
Help directly fund development: Donate via PayPal!

vincent-b's picture
Offline
Joined: 07/17/2009
Juice: 2
Re: Re: BigMike wrote:Ok, I think

OK, I have the same problem. I'm building a websit for a clothing company. THey have dozens of products, all available in a wide range of fabrics (more than 30 types for one collection and there's 5 collections) and colors (more than 50 colors)... It's very high quality ready to wear and sur-mesure clothes. if you pay the price you're able to select every options, but for the main range of ready to wear, each model is proposed with two fabrics and two colors max... So I basically arrives on the option page and have to uncheck hundreds of checkboxes...

I was using a firefox extension to "uncheck all", and my developper just granted me with a javascript link in the form that does that too... but i'm surprise we're not able to reverse the default check option.

z3b
z3b's picture
Offline
Joined: 08/15/2007
Juice: 51
Re: "Select All" "Deselect All" for Attribute Options page, plea

Came up with a more or less satisfying jQuery solution, at least it doesn't require to hack UC files. Hope that helps

/**
* Implementation of hook_init().
*/
function dormeuilhooks_init() {
  $js = '$(document).ready(function(){';
  $js .= '$("#uncheck-all-checkbox").click(function(){';
  $js .= '$("#uc-object-options-form").find("input[@type$=\'checkbox\']").each(function(){ this.checked = false; });';
  $js .= '});});';
  drupal_add_js($js, 'inline');
}

/**
* Implementation of hook_form_alter().
*/
function dormeuilhooks_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'uc_object_options_form') {
    drupal_set_message(t('You might want to').' <a href="#" onclick="return false;" id="uncheck-all-checkbox">'.t('uncheck all options').'</a>');
  }
}

colinjallen's picture
Offline
Joined: 08/04/2009
Juice: 2
Using custom module, almost

I would like to deselect all of the options through a custom module, so this module can be updated in the future and the custom hack will not get lost. I just need a little help with the first if statement. If someone could help me out, it would be appreciated.

Here is the code:

<?php

function mb_custom_form_alter(&$form, &$form_state, $form_id) {

if ($form == 'uc_object_attributes_form') { /** THIS LINE NEEDS TO BE CORRECTED **/
$form["#submit"][] = 'mb_attribute_form_submit';
}

}

function mb_attribute_form_submit($form, &$form_state) {
if($form_state['values']['view'] == 'add') {
$attribute = uc_attribute_load($aid);
foreach ($attribute->options as $option) {
db_query("DELETE FROM {uc_product_options} WHERE nid = %d AND oid = %d", $form_state['values']['id'], $option->oid);
}
}
}

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4110
Re: Using custom module, almost

try $form_id instead. When in doubt, do

<?php
drupal_set_message
($form_id);
?>

to see what the form is that you are inside of.

--
Help directly fund development: Donate via PayPal!

pari's picture
Offline
Joined: 07/24/2010
Juice: 16
z3b wrote: Came up with a
z3b wrote:

Came up with a more or less satisfying jQuery solution, at least it doesn't require to hack UC files. Hope that helps

/**
* Implementation of hook_init().
*/
function dormeuilhooks_init() {
  $js = '$(document).ready(function(){';
  $js .= '$("#uncheck-all-checkbox").click(function(){';
  $js .= '$("#uc-object-options-form").find("input[@type$=\'checkbox\']").each(function(){ this.checked = false; });';
  $js .= '});});';
  drupal_add_js($js, 'inline');
}

/**
* Implementation of hook_form_alter().
*/
function dormeuilhooks_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'uc_object_options_form') {
    drupal_set_message(t('You might want to').' <a href="#" onclick="return false;" id="uncheck-all-checkbox">'.t('uncheck all options').'</a>');
  }
}

Not working for me (anyway thank you for direction) so I fixed it like this:

/**
* Implementation of hook_form_alter().
*/
function MODULENAME_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'uc_object_options_form') {
    drupal_add_js('$(document).ready(function(){
        $("#uncheck-all-checkbox").click(function(){
            $("#uc-object-options-form").find("input[type=checkbox]").each(function(){ this.checked = false; });
        });
    });', 'inline');
    drupal_set_message(t('You might want to').' <a href="#" onclick="return false;" id="uncheck-all-checkbox">'.t('uncheck all options').'</a>');
  }
}