Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Easy Digital Downloads - Deselect other multicheck pricing options when last one is selected
<?php
function sumobi_edd_deselect_other_price_options() {
if ( ! edd_has_variable_prices( get_the_ID() ) )
return;
?>
<script>
jQuery(document).ready(function ($) {
// get each purchase form
var purchaseForm = $( '.edd_download_purchase_form' );
$( purchaseForm ).each(function( index ) {
var allCheckBoxes = $( "input[type=checkbox]", this ),
last = allCheckBoxes.last();
// last checkbox is clicked
$( last ).click( function() {
// check to see if it's checked
if ( $( this ).prop('checked') ) {
// deselect all other checkboxes
$( allCheckBoxes ).not( this ).prop( "checked", false );
}
});
});
});
</script>
<?php
}
add_action( 'wp_footer', 'sumobi_edd_deselect_other_price_options' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment