Created
June 4, 2021 14:14
-
-
Save Basilakis/bc8b6f7d0cc7ca1aa7cbc54852e002df to your computer and use it in GitHub Desktop.
Easy Digital Downloads - Un check all other options on a multiselect pricing, and leave only the last selected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Un check all other options on a multiselect pricing, and leave only the last selected | |
*/ | |
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