Support

Home Forums Event Espresso Premium Add Select for attendee dropdown

Add Select for attendee dropdown

Posted: July 9, 2014 at 3:49 am


Ben

July 9, 2014 at 3:49 am

Hi Guys,

I’m looking to add ‘Select’ above the attendee dropdown. What is the best way to do this, and why can’t I get the CSS working to position the text over to the right?

http://screencast.com/t/bW5TR5D5WfX

Is it possible to get the code above the dropdown so its in the same table box. This solution has evolved, as replacing ‘0’ with ‘Select’ is not possible. I have already installed Josh’s jquery suggestion so the list begins with 1 instead of 0.

Thanks.


Tony

  • Support Staff

July 9, 2014 at 4:54 am

Hi Ben,

How are you currently adding that string?


Ben

July 9, 2014 at 4:59 am

Thanks Tony.

First I added it as a php echo, and now its just p class.

Do I need to move it back to a php echo string?

Thanks.


Tony

  • Support Staff

July 9, 2014 at 5:34 am

Sorry I should have been clearer.

Are you currently adding that to a template file, if so which file?

It looks like you are adding that to shopping_cart.php is that correct?

The problem is the cart uses a function that builds the full list, this section http://take.ms/jXruz

The only way to add the text above that dropdown and display it consistently is to either edit a core file, or override it (as it is a pluggable function) I would recommend overriding it, however if we make changes to the original function these will need to be transferred to your ‘custom’ function also which would be down to yourself.

The function you need to edit is event_espresso_group_price_dropdown() which is within event-espresso/includes/functions/cart.php

If you add:

Select:

on line 1235, you end up with something like this – http://take.ms/1vwGo

Does that help?


Ben

July 9, 2014 at 6:04 am

That’s fantastic Tony. Yes, to answer your questions, just the wrong template. Thanks. http://screencast.com/t/ezCzk9yxt

Thank you very much.


Ben

July 9, 2014 at 7:17 am

One last thing Tony, is it possible to remove the 0 (Zero) from the event_espresso_group_price_dropdown ?

Thanks.


Lorenzo Orlando Caum

  • Support Staff

July 9, 2014 at 7:33 am

jQuery can handle this:

http://stackoverflow.com/questions/1518216/jquery-remove-options-from-select


Lorenzo


Ben

July 9, 2014 at 8:51 am

Thanks Lorenzo,

Is there something I’m missing here, as the ‘0’ still appears in the drop down?

<pre class=”brush: javascript; gutter: true; first-line: 1; highlight: []; html-script: false”><script>jQuery(document).ready(function(){
jQuery(".price_id").val(1);
jQuery('#event_espresso_refresh_total').trigger('click');
});
</script>
<script>
$(".price_id option[value='0']").each(function() {
$(this).remove();
});
</script>


Lorenzo Orlando Caum

  • Support Staff

July 9, 2014 at 9:36 am

<script>jQuery(document).ready(function(){
jQuery(".price_id").val(1);
jQuery('#event_espresso_refresh_total').trigger('click');
});
</script>
<script>
jQuery(document).ready(function(){
jQuery(".price_id option[value='0']").each(function() {
jQuery(this).remove();
});
</script>


Ben

July 9, 2014 at 10:37 am

Thanks Lorenzo,

I’m still getting a syntax error on line 170 – http://screencast.com/t/Q9WWfFNh

Any ideas what’s missing?

Thanks.


Lorenzo Orlando Caum

  • Support Staff

July 9, 2014 at 10:43 am

Hello,

It should be gone unless there is a different class or id that is needed:

https://eventespresso.com/wiki/setup-default-value-1-ticket-selector/

What is the URL?


Lorenzo


Ben

July 9, 2014 at 10:54 am

Thanks Lorenzo.

The url is – http://bhwclub.org/espresso-events/?regevent_action=show_shopping_cart
You might need to go back to add an event though.

Thanks.


Lorenzo Orlando Caum

  • Support Staff

July 9, 2014 at 11:22 am

Alright, please see this: http://jsfiddle.net/xUCf2/

This try this revised code:

https://gist.github.com/lorenzocaum/6683b64ea28589a1afc6

You can paste that into your child themes functions.php file or just copy out the javascript part and replace your existing code.


Lorenzo


Ben

July 9, 2014 at 11:43 am

That is awesome Lorenzo. Thanks.

Cheers for the JS Fiddle link too, must try that going forwards.

Thanks.

The support post ‘Add Select for attendee dropdown’ 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