Created
December 19, 2019 06:16
-
-
Save trueqap/4eb59e47073a6c633bd037940a125f1d to your computer and use it in GitHub Desktop.
WooCommerce disable BACS for subscriptions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function woo_disable_bacs_for_subscriptions( $available_gateways ) { | |
global $wp; | |
if ( class_exists( 'WC_Subscriptions_Cart' ) ) { | |
// 2.6+ compatibility | |
$cart_contains_renewal = function_exists( 'wcs_cart_contains_renewal' ) ? wcs_cart_contains_renewal() : WC_Subscriptions_Cart::cart_contains_subscription_renewal(); | |
if ( is_checkout_pay_page() ) { | |
$order_contains_renewal = function_exists( 'wcs_order_contains_subscription' ) ? wcs_order_contains_subscription( $wp->query_vars['order-pay'] ) : WC_Subscriptions_Order::order_contains_subscription( $wp->query_vars['order-pay'] ); | |
} else { | |
$order_contains_renewal = false; | |
} | |
if ( WC_Subscriptions_Cart::cart_contains_subscription() || $cart_contains_renewal || $order_contains_renewal || WC_Subscriptions_Change_Payment_Gateway::$is_request_to_change_payment ) { | |
if ( isset( $available_gateways['bacs'] ) ) { | |
unset( $available_gateways['bacs'] ); | |
} | |
} | |
} | |
return $available_gateways; | |
} | |
add_filter( 'woocommerce_available_payment_gateways', 'woo_disable_bacs_for_subscriptions', 11 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment