Support

Home Forums Event Espresso Premium Force price selection (no default price)

Force price selection (no default price)

Posted: February 8, 2013 at 11:18 am

Viewing 3 reply threads


SCLR Tech Editor

February 8, 2013 at 11:18 am

Is there any way to have the price selection drop-down menu not default to the first option? I have some customers who seem to be skipping over this field and end up paying the default price. I would like to force them to have to make a selection.


Dean

February 11, 2013 at 1:07 am

Hi,

Well there are two options really, but both require code.

The first would be to edit a core file to add the required class to the dropdown and insert a blank selection at the top. This isnt ideal as you are changing a core file.

event-espresso/includes/functions/pricing.php, you would need to edit the espresso_price_select function.

The other option is to add some jQuery to the registration_page_display.php template to do the same. Issue with this is it wont work if javascript is turned off.

<script>
    jQuery(document).ready( function() {
            //get the event id                       
            var the_event_id = <?php echo json_encode($event_id) ?>;
            //add blank value to the top of the list and make it default.
            jQuery("#price_option-" + the_event_id ).prepend("<option value=''></option>").val('');
            //add required class to the options lists to force validation so an item has to be selected.
            jQuery("#price_option-" + the_event_id ).addClass('required'); 
    });
</script>


SCLR Tech Editor

February 14, 2013 at 10:32 am

Dean, Thanks for getting me started in the right direction – I did have to make a couple of tweaks to the code, and ended up with the following:

jQuery(document).ready(function($) {
//get the event id
var the_event_id = document.URL;
the_event_id = the_event_id.substr(the_event_id.indexOf("?ee=")+4, the_event_id.length-the_event_id.indexOf("?ee=")-4);
//add blank value to the top of the list and make it default.
jQuery("#price_option-" + the_event_id ).prepend("").val('');
//add required class to the options lists to force validation so an item has to be selected.
jQuery("#price_option-" + the_event_id ).addClass('required');

});


Dean

February 14, 2013 at 11:52 pm

Hey,

No problem and thanks for sharing your updated code.

Viewing 3 reply threads

The support post ‘Force price selection (no default price)’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso