-
-
Save Pebblo/737310c7309436231008666ac27e9662 to your computer and use it in GitHub Desktop.
Testing out using jQuery to swap the TS select element for a checkbox, if the checkbox is selected the 'first' value of the Qty select field is used.
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
<?php //Please do not include the opening PHP tag if you already have one | |
function tw_ee_ticket_selector_replace_qty_select_with_checkboxes() { | |
wp_add_inline_script( | |
'ticket_selector', | |
'jQuery( document ).ready(function($) { | |
$(".tckt-slctr-tbl-td-qty select").each(function(){ | |
$(this).before("<input class=\'" + this.id + "\' type=\'checkbox\'>"); | |
$(this).hide(); | |
$(".tckt-slctr-tbl-td-qty input:checkbox").change(function(){ | |
if(this.checked) { | |
var select = $("#" + $(this).attr("class")); | |
let value = select.find("option:eq(1)").val(); | |
select.val(value).change(); | |
} | |
}); | |
}); | |
});' | |
); | |
} | |
add_action( 'wp_enqueue_scripts', 'tw_ee_ticket_selector_replace_qty_select_with_checkboxes', 11 ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment