Jump to content
Sign in to follow this  

QTPro - Multiple dropdowns - Please select option

Recommended Posts

Hi all


I've been struggling to find a way to add a "Please select" option to the Multiple Dropdowns that are part of the QTPro contribution. Its set to select the default value for the stock options (products_options_values_id) when the pick list is drawn, so however you order your stock attributes the top item is always selected as the default value for the pick list. Can't seem to find a way to insert an add text option as the default into the coding that is drawing up the pick lists in pad_multiple_dropdowns.php.


Searched the forums and contributions etc, seems like no one has managed this and fed back, lots of people asking how to do this. The best result is a hack at the top level in html_output.php where you add a "please select.." to all pick lists.


just above:

for ($i=0, $n=sizeof($values); $i<$n; $i++) {



$field .= '<option value="select"';

$field .= '>Please Select ...</option>';


This is great and thanks for sharing Megan, but this is only part of the way there. This applies "Please select..." to every pick list in the site and the developer has no ability to vary the default for pick lists from Please select. i.e. I like to have United Kingdom at the top of the countries pick list.


So, I'm hoping that someone has managed to do this ...(apply a text default of "please select" or similar) direct to the multiple dropdown pick lists created by the QT Pro contribution


and may be willing to share the code they created to do this? Surely someone has found a way?

Share this post

Link to post
Share on other sites

Ok, so I managed to do it, but it throws up other problems. Firstly here's how you can add a Please select direct to the multiple dropdowns created by QTpro, amend the coding in this file:


includes/classes/pad_multiple_dropdowns.php about line 92



      $out.='<tr><td align="right" class=main><b>'.$attributes[$o]['oname'].":</b></td><td class=main>".tep_draw_pull_down_menu('id['.$attributes[$o]['oid'].']',array_values($attributes[$o]['ovals']),$attributes[$o]['default'], "onchange=\"stkmsg(this.form);\"")."</td></tr>\n"; 

      $out.='<tr><td align="right" class=main><strong>'.$attributes[$o]['oname'].":</strong></td><td class=main>".tep_draw_pull_down_menu('id['.$attributes[$o]['oid'].']',array_merge(array(array('id'=>"", 'text'=>'Please select ')), $attributes[$o]['ovals']),$attributes[$o]['default'], "onchange=\"stkmsg(this.form);\"")."</td></tr>\n";


This does what I initially wanted, add a Please select option direct to the multiple dropdown pick lists, without affecting any other pick lists in the site.


However, when the please select option is highlighted, i.e. as soon as they view the product page it is generating the Out of Stock message. The out of stock message is generated whenever the combined option values of the pick lists = 0 or less. I had hoped that by leaving the option value blank " "


instead of "0" that would do the trick and get rid of the Out of Stock message.


It didn't, so somewhere in the code a blank option value is also triggering the out of stock message. I'm now trying to find a way to make it ignore the blank value (so not bring up the Out of stock message on a blank option value), but without allowing the 'Please select' entry on the pick list to be added to the basket.


I think I need to tweek the code for function _draw_out_of_stock_message_js also in includes/classes/pad_multiple_dropdowns.php


If I manage it, I'll feed back. If anyone manages this, please feed back also, even if its some time later.. I look through old posts for solutions all the time, its invaluable!

Share this post

Link to post
Share on other sites

ok I was looking at this the wrong way really. I was getting tied up in the option value setting, rather than the stock quantities it was generating. But the solution, and definitely a hack is very simple. In includes/classes/pad_multiple_dropdowns.php about line 160 it says this



       //initialize out of stock message
       $out.="  stkmsg(document.cart_quantity);\n";


Just // it out. Basically if you get rid of this line of code it will NOT generate the Out of Stock message when the page is first opened. Which is fine, because at that point both pick list say Please select. The customer still cannot add these to their basket - this doesn't interfere with them being red as 0 quantity and the Out of stock message on 0 quantity will work as soon as they select something from the pick list, because this message is also attached to a onchange event on the pick lists.


Ok if once you have changed the pick lists and then go back to Please select the out of stock message will appear once again, but does it matter!?

Share this post

Link to post
Share on other sites

Just wanted to say a big thank you Roseweb for your post. I've been looking and searching far and wide on how to stop the out of stock message from showing up when the page loads. This did the trick!

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this