Skip to content

Instantly share code, notes, and snippets.

@raftaar1191
Last active February 14, 2023 07:33
Show Gist options
  • Save raftaar1191/766518224667a17d6e47d6ff5bb5706c to your computer and use it in GitHub Desktop.
Save raftaar1191/766518224667a17d6e47d6ff5bb5706c to your computer and use it in GitHub Desktop.
Always save the Stripe Credit card details Token into the site for later use
/**
* Always save card token for stripe: Save payment information to my account for future purchases.
*/
add_filter( 'wc_stripe_force_save_source', '__return_true' );
/**
* Filter the HTML of the stripe credit card details
*/
function payment_gateway_field_html_stripe_callback( $field_html ) {
$field_html = str_ireplace( '<fieldset', 'style=display:none; <fieldset', $field_html );
$field_html = str_ireplace( 'id="wc-stripe-new-payment-method', 'checked id="wc-stripe-new-payment-method', $field_html );
return $field_html;
}
add_filter( 'cfw_payment_gateway_field_html_stripe', 'payment_gateway_field_html_stripe_callback', 10 );
@raftaar1191
Copy link
Author

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