Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Last active April 13, 2020 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshfeck/0e2e59c39a36b76cc65a3b92f9543c79 to your computer and use it in GitHub Desktop.
Save joshfeck/0e2e59c39a36b76cc65a3b92f9543c79 to your computer and use it in GitHub Desktop.
Add a tickets remaining column to the Event Espresso ticket selector. Requires displaying ticket selector details section.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_action('wp_enqueue_scripts', 'my_add_inline_script_ts_show_sale_info', 20);
function my_add_inline_script_ts_show_sale_info() {
$custom_js = '
jQuery(document).ready(function($){
$(".ee-ticket-selector-ticket-details-th").after("<th class=\'cntr\' scope=\'col\'>Tickets Remaining</th>");
$("td[data-th=\'Remaining\']").each(function() {
$(this).clone().insertAfter(
$(this).parents("tr.tckt-slctr-tkt-details-tr").prev("tr.tckt-slctr-tbl-tr").find(".tckt-slctr-tbl-td-name")
);
});
});';
wp_add_inline_script('ticket_selector', $custom_js);
}
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
// translated version of above
add_action('wp_enqueue_scripts', 'my_add_inline_script_ts_show_sale_info_tr', 20);
function my_add_inline_script_ts_show_sale_info_tr() {
$custom_js = '
jQuery(document).ready(function($){
$(".ee-ticket-selector-ticket-details-th").after("<th class=\'cntr\' scope=\'col\'>Resterend</th>");
$("td[data-th=\'Resterend\']").each(function() {
$(this).clone().insertAfter(
$(this).parents("tr.tckt-slctr-tkt-details-tr").prev("tr.tckt-slctr-tbl-tr").find(".tckt-slctr-tbl-td-name")
);
});
});';
wp_add_inline_script('ticket_selector', $custom_js);
}
@hermiejc
Copy link

Hi good day!
I tried this script, if I copy the JS itself only the heading is working, without the data in table list. If I put in PHP file, it's not working at all. Please help me in this. Thank you.

@joshfeck
Copy link
Author

Hi,

Can you start a topic in the support forums at eventespresso.com? We can help you there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment