Home Uncategorized WooCommerce Stripe – Always remember Credit card

WooCommerce Stripe – Always remember Credit card

82

I am using the WooCommerce Stripe plugin.

When a user checks out, they are presented with the option to save their payment method.Stripe Because I sell subscriptions, I need to always save the payment information, so I don’t want to give the customer the choice.

To accomplish that, I created a custom plugin, which will ensure the change survives rounds of updates.

This plugin uses CSS to hide the checkbox while setting the value “checked” in the backend.

To use this plugin, create a directory name wp-content/plugins/always-save-credit-card, and inside it, a file always-save-credit-card.php

Like this:

wordpress/
├─ wp-admin/
├─ wp-content/
│   ├─ plugins/
│   │   ├─ always-save-credit-card/
│   │   │   ├─ always-save-credit-card.php

Then, inside the file php file, put this content.

<?php
/**
 * Plugin Name: Custom Stripe Remember Me
 * Description: A custom plugin to force saving the payment information when a user checks out using the Stripe WooCommerce integration.
 * Version: 1.0.0
 * Author: koff
 * License: GPL-2.0+
 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
 */

function custom_wc_stripe_force_save_source($force_save_source, $source) {
    return true;
}
add_filter('wc_stripe_force_save_source', 'custom_wc_stripe_force_save_source', 10, 2);

function custom_hide_stripe_remember_me_css() {
    echo '<style>#wc-stripe-new-payment-method { display: none!important; }</style>';
    echo '<style>.woocommerce-SavedPaymentMethods-saveNew { display: none!important; }</style>';
}
add_action('wp_head', 'custom_hide_stripe_remember_me_css');

Finally, navigate to the admin panel of your site, and there, go to the plugins section, and activate your new plugin.

82 COMMENTS