1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
<?php
defined( 'ABSPATH' ) || exit();
class WC_Stripe_Gateway_Conversion {
public static function init() {
add_filter( 'woocommerce_order_get_payment_method', array( __CLASS__, 'convert_payment_method' ), 10, 2 );
add_filter( 'woocommerce_subscription_get_payment_method', array( __CLASS__, 'convert_payment_method' ), 10, 2 );
}
public static function convert_payment_method( $payment_method, $order ) {
$old_payment_method = $payment_method;
switch ( $payment_method ) {
case 'stripe':
if ( did_action( 'woocommerce_checkout_order_processed' ) ) {
return $payment_method;
}
$payment_method = 'stripe_cc';
break;
}
return $payment_method;
}
}
WC_Stripe_Gateway_Conversion::init();