Post by altsheepy » Fri Nov 25, 2011 1:18 am

Hi all,

Instead of having ---please select-- as the default option, is there a way i can set the default selected option in open cart?

Any help would be very much appreciated.

Regards

Newbie

Posts

Joined
Fri Nov 25, 2011 1:04 am

Post by florinsith » Fri Nov 25, 2011 4:46 am

In what instance , where?

Image
My Extensions - SuperTheme - Opencart templates - Opencart modules


User avatar
Newbie

Posts

Joined
Fri May 14, 2010 2:36 am


Post by altsheepy » Fri Nov 25, 2011 5:08 am

Sorry my site is down at the moment and i am unable to link it, but basically. When purchasing a product, i added options , for example

Processor 0
Processor 1 +250
Processor 2 +300

When the customer selects the product, the drop-down box shows the following

---please select----
Processor 0
Processor 1 + 250
Processor 2 + 300

Where --please select-- is the default selection. I would like to set a default selection for the product if the customer makes no action.

This can be clearly seen on open cart's demo site.

http://demo.opencart.com/index.php?rout ... duct_id=42

The page loads with no default selections on any of the options. Can i set a default?

Thank you for the help!.

Newbie

Posts

Joined
Fri Nov 25, 2011 1:04 am

Post by florinsith » Fri Nov 25, 2011 5:12 pm

Edit the file catalog/view/theme/yourtheme/template/product/product.tpl

and look into this piece of code
<?php if ($option['type'] == 'select') { ?>
<div id="option-<?php echo $option['product_option_id']; ?>" class="option">
<?php if ($option['required']) { ?>
<span class="required">*</span>
<?php } ?>
<b><?php echo $option['name']; ?>:</b><br />
<select name="option[<?php echo $option['product_option_id']; ?>]">
<option value=""><?php echo $text_select; ?></option>
<?php foreach ($option['option_value'] as $option_value) { ?>
<option value="<?php echo $option_value['product_option_value_id']; ?>"><?php echo $option_value['name']; ?>
<?php if ($option_value['price']) { ?>
(<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
<?php } ?>
</option>
<?php } ?>
</select>
</div>
<br />
<?php } ?>
The line that you see highlited (<option value=""><?php echo $text_select; ?></option>) delete that and then the default option will be the first one entered in admin.

Image
My Extensions - SuperTheme - Opencart templates - Opencart modules


User avatar
Newbie

Posts

Joined
Fri May 14, 2010 2:36 am


Post by altsheepy » Fri Nov 25, 2011 9:28 pm

Thank you so much! it worked!. is there a way to also do this for radio buttons? This worked for the dropdown box type selection.

Newbie

Posts

Joined
Fri Nov 25, 2011 1:04 am

Post by nolaweb » Thu Dec 01, 2011 7:08 am

v 1.51.

Overview - Under the next option (radio) modify as outlined here. Put a flag and set to 1, check with if and echo cheked for first run through loop, then set flag to 2,

<?php if ($option['type'] == 'radio') { ?>

<div id="option-<?php echo $option['product_option_id']; ?>" class="option">
<?php if ($option['required']) { ?>
<span class="required">*</span>


<?php } ?>
<b><?php echo $option['name'];
// Set the flag
$checkit = 1; ?>:</b><br />
<?php foreach ($option['option_value'] as $option_value) { ?>
<input type="radio" name="option[<?php echo $option['product_option_id']; ?>]"

// echo if it's the first radio
<?php if($checkit ==1) echo "checked=\"1\"" ?>

value="<?php echo $option_value['product_option_value_id']; ?>" id="option-value-<?php echo $option_value['product_option_value_id']; ?>" />
<label for="option-value-<?php echo $option_value['product_option_value_id']; ?>"><?php echo $option_value['name']; ?>
<?php if ($option_value['price']) { ?>
(<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
<?php } ?>
</label>
<br />

<?php
// set flag to 2 so it doesn't check next radio
$checkit = 2; } ?>
</div>
<br />
<?php } ?>

Newbie

Posts

Joined
Thu Dec 01, 2011 7:02 am

Post by redleaf » Wed Nov 27, 2013 8:30 pm

Sorry to dig up such an old thread but it seemed relevant.

I want to change the select list from "Please Select" but instead of the first option I want the second option selected by default on a great many of my products. Is this possible?

I have all my options sorted by price and I would prefer to keep them that way however my cheapest option is a small sample of my product that isn't really a good example of the starting price of my products

Example list

Sample $2
Regular $10
Large $15
X Large $20

Most customers buy regular and there is no real value in defaulting to the Sample price

Of course to make it even more difficult there may be times when I don't want to do this and would prefer to default to the first option as some of my products don't have sample options

If anyone has any ideas I'd appreciate it

Newbie

Posts

Joined
Wed Nov 27, 2013 8:19 pm

Post by rmullaney77 » Wed Dec 04, 2013 2:51 am

I would just adjust the sort order of your options (eg: set "Sample" sort to 9999)

Developer BlogMy ExtensionsOpen Cart Templates

Buy me a cup of coffee... ;)


User avatar
Newbie

Posts

Joined
Fri Nov 19, 2010 2:08 am
Location - Lakeland, Florida

Post by opencart-sk » Thu Jan 30, 2014 2:45 am

Hi, please how to solve this problem? Deleting line 86 in product.tpl:

Code: Select all

<option value=""><?php echo $text_select; ?></option>
does not work in 1.5.6.1 :(

Newbie

Posts

Joined
Sun Jan 19, 2014 5:28 pm

Post by dantheman50_98 » Thu Jul 17, 2014 12:53 am

Ditto, not working in 1.5.5.1 either. Help please!


Posts

Joined
Sat Sep 18, 2010 2:18 am

Post by florinsith » Fri Jul 18, 2014 4:32 pm

How does it not work? Is there some error, something breaks? because since the please select option is not there anymore it cant still apear.

Image
My Extensions - SuperTheme - Opencart templates - Opencart modules


User avatar
Newbie

Posts

Joined
Fri May 14, 2010 2:36 am


Post by dantheman50_98 » Fri Jul 18, 2014 6:58 pm

Thanks for the reply, it turns out the options settings extension I'm using was putting it back in via vqmod. Now sorted.


Posts

Joined
Sat Sep 18, 2010 2:18 am

Post by Manus » Tue Jun 23, 2015 4:38 pm

Hey guys,

I know this is an old thread, but how would I modify the coding to work on OpenCart 2.0.3? I have been trying to implement this into the product.tpl document of my OpenCart 2.0.3 installation and I just don't have the know-how to achieve this successfully. I only want this to apply to the radio options.

Assistance will be greatly appreciated. Thanks.

Newbie

Posts

Joined
Tue May 06, 2014 5:20 pm

Post by ronnieb » Mon Mar 27, 2017 3:14 am

as above look for <option value=""><?php echo $text_select; ?></option> in theme/*/product.tpl and delete it

Newbie

Posts

Joined
Tue May 24, 2011 3:44 pm

Post by wh1t3man2nd » Fri Apr 21, 2017 8:46 pm

Hello,
Even though its an old thread i tried it in ver 2.3.0.2 and nothing happens.
I removed ( <option value=""><?php echo $text_select; ?></option> ) and the "Please select" option remains.
Any ideas on how to do it??
Thank you.

Newbie

Posts

Joined
Wed Apr 19, 2017 8:27 pm
Who is online

Users browsing this forum: Google [Bot] and 49 guests