Skip to content

Instantly share code, notes, and snippets.

@spivurno
Last active April 10, 2022 21:15
Show Gist options
  • Select an option

  • Save spivurno/66e0d36495b7c1ed9444d6e77ecf168e to your computer and use it in GitHub Desktop.

Select an option

Save spivurno/66e0d36495b7c1ed9444d6e77ecf168e to your computer and use it in GitHub Desktop.
Gravity Perks // GP Copy Cat // Copy Credit Card Name to Name Field
<script>
/**
* Gravity Perks // GP Copy Cat // Copy Credit Card Name to Name Field
* http://gravitywiz.com/
*/
gform.addFilter( 'gppc_copied_value', function( value, $targetElem, field ) {
if( field.source.split( '.' ).pop() != 5 ) {
return value;
}
$source = jQuery( '#input_' + field.sourceFormId + '_' + field.source.split( '.' ).join( '_' ) );
if( $source.parents( '.ginput_container_creditcard, .ginput_container_custom_card_fields' ).length <= 0 ) {
return value;
}
// Stripe removes the "name" attribute so that the input's value is not submitted; GPCC does not account for this
// so let's get the value from our source input.
value = $source.val();
var $span = $targetElem.parents( 'span' );
if( $span.hasClass( 'name_first' ) ) {
value = value.split( ' ' ).shift();
} else if( $span.hasClass( 'name_last' ) ) {
values = value.split( ' ' );
values.shift();
value = values.join( ' ' );
}
return value;
} );
</script>
@spivurno
Copy link
Copy Markdown
Author

@Wordna1 Thanks for the tip! Added it the class list so it'll support both.

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