Last active
April 18, 2019 13:28
-
-
Save Pebblo/19b04ccefc13e109ad52bdd73002907a to your computer and use it in GitHub Desktop.
Example of how to override the SPCO.calculate_target_attendee_input_id method so that you can exclude specific inputs from being copied.
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 | |
// This function allows you to set inputs to be skipped during the copy attendee info function shown on SPCO. | |
// It currently skips the 'fname', 'lname', 'email' questions but you can add your own input ID's to the exclude_array. | |
function tw_ee_exclude_inputs_from_spco_copy_function() { | |
wp_add_inline_script( | |
'single_page_checkout', | |
"jQuery( document ).ready(function($) { | |
SPCO.calculate_target_attendee_input_id = function ( primary_reg_input, targeted_attendee) { | |
var new_input_id = ''; | |
// here we go again... | |
var input_id = jQuery(primary_reg_input).attr('id'); | |
//SPCO.console_log( 'calculate_target_attendee_input_id : input_id', input_id, true ); | |
if ( typeof input_id !== 'undefined' ) { | |
// split the above var | |
var input_id_array = input_id.split('-'); | |
//SPCO.console_log( 'calculate_target_attendee_input_id : input_id_array', input_id_array, false ); | |
// grab the current input's details | |
var qstn_base = input_id_array[0]; | |
//var reg_id = input_id_array[1]; | |
var input_name = input_id_array[2]; | |
var answer_id = input_id_array[3]; | |
// var input_value = $(this).eeInputValue(); | |
// SPCO.console_log( 'calculate_target_attendee_input_id : input_name', input_name, false ); | |
// Setup input exclusions array | |
var exclude_array = [ | |
'fname', | |
'lname', | |
'email' | |
]; | |
// Check if the primary reg input id is in the array, if so, skip it by not returning an input ID | |
if( exclude_array.indexOf(input_name) > -1 ) { | |
//SPCO.console_log( 'calculate_target_attendee_input_id : input_name', input_name, false ); | |
return ''; | |
} | |
new_input_id = '#' + qstn_base + '-' + targeted_attendee + '-' + input_name; | |
if ( typeof answer_id !== 'undefined' ) { | |
new_input_id = new_input_id + '-' + answer_id; | |
} | |
//SPCO.console_log( 'calculate_target_attendee_input_id : new_input_id', new_input_id, false ); | |
} | |
return new_input_id; | |
} | |
});" | |
); | |
} | |
add_action( 'wp_enqueue_scripts', 'tw_ee_exclude_inputs_from_spco_copy_function', 11 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment