Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

QTPro - Multiple dropdowns - Please select option


Rosyweb

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++) {

 

add

$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?

Link to comment
Share on other sites

  • 1 month later...

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

 

ORIGINAL: 

      $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"; 

CHANGE:       
      $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 " "

('id'=>""

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!

Link to comment
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!?

Link to comment
Share on other sites

  • 1 year later...
  • 8 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...