Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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