Skip to content

Instantly share code, notes, and snippets.

@woogist
Created August 13, 2015 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save woogist/e077f2530228640831c2 to your computer and use it in GitHub Desktop.
Save woogist/e077f2530228640831c2 to your computer and use it in GitHub Desktop.
function wcsdp_only_allow_paypal_for_subscriptions( $available_gateways ) {
global $wp;
if ( class_exists( 'WC_Subscriptions_Cart' ) ) {
if ( WC_Subscriptions_Cart::cart_contains_subscription() || WC_Subscriptions_Cart::cart_contains_subscription_renewal() || ( is_checkout_pay_page() && WC_Subscriptions_Order::order_contains_subscription( $wp->query_vars['order-pay'] ) ) ) {
if ( isset( $available_gateways['paypal'] ) ) {
return array( 'paypal' => $available_gateways['paypal'] );
}
}
}
return $available_gateways;
}
add_filter( 'woocommerce_available_payment_gateways', 'wcsdp_only_allow_paypal_for_subscriptions', 11 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment