Support

Home Forums Event Espresso Premium Pre-checked checkbox in the checkout

Pre-checked checkbox in the checkout

Posted: April 24, 2015 at 10:06 am

Viewing 6 reply threads


Brett McCumber

April 24, 2015 at 10:06 am

Hi there,

I’m trying to have a pre-checked checkbox in the checkout page. I know using jquery I can use the following:

$(document).ready(function(){
$('.checkbox').prop('checked', true);
});

But I’m just not sure in what file and where to put it in. Please advise. Thank you.


Brett McCumber

April 24, 2015 at 10:06 am

Hi there,

I’m trying to have a pre-checked checkbox in the checkout page. I know using jquery I can use the following:

$(document).ready(function(){
$('#Yes-358_1').prop('checked', true);
});

But I’m just not sure in what file and where to put it in. Please advise. Thank you.


Dean

April 27, 2015 at 1:26 am

Hi,

Personally I would add it to a site specific plugin (https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/), something like:

add_action('wp_footer', 'checkthis');
function checkthis() {

	if( is_page(4) ) {
		?>
		<script>
		jQuery(document).ready(function(){
		jQuery('#ee_reg_qstn-30-12-one').prop('checked', true);
		});
		</script>
		<?php
	}
}

Which will add the script to the footer area.


Brett McCumber

April 27, 2015 at 10:13 am

Thank you.


Brett McCumber

May 8, 2015 at 9:57 am

It works when using Cart or Registering only one Attendee. When I use “Add more attendees” option the checkbox stays unchecked.

Code used:

add_action('wp_footer', 'checkthis');
function checkthis() {
		?>
		<script>
		jQuery(document).ready(function(){
		jQuery('.MULTIPLE_13').prop('checked', true);
		});
		</script>
		<?php
}

Screenshot


Lorenzo Orlando Caum

  • Support Staff

May 8, 2015 at 10:55 am

Hi, this doesn’t work as expected because those additional fields are activated as you add additional attendees by clicking on the button.

The jQuery runs on the initial page load so it won’t be able to pick those up afterwards.


Lorenzo


Brett McCumber

May 8, 2015 at 11:13 am

Would I be able to run the script every time the button clicked? What file can I fin that in?

Thank you Lorenzo. You are and have been a huge help!


Lorenzo Orlando Caum

  • Support Staff

May 11, 2015 at 7:39 am

Hi, that would not work as expected since the sample jQuery that was shared is set to run on the initial page load.


Lorenzo

Viewing 6 reply threads

The support post ‘Pre-checked checkbox in the checkout’ 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