Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'woocommerce_available_payment_gateways', function ( $available_gateways ) {
- if(is_admin()) return $available_gateways;
- $membership_product = false;
- foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) {
- $_product = apply_filters('woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key);
- if ($_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters('woocommerce_checkout_cart_item_visible', true, $cart_item, $cart_item_key)) {
- $membership_id = get_post_meta($_product->get_id(), '_wcfm_membership', true);
- if(wcfm_is_valid_membership($membership_id)) {
- $membership_product = true;
- break;
- }
- }
- }
- if($membership_product && isset( $available_gateways['stripe_split'] ) ) {
- unset($available_gateways['stripe_split']);
- } elseif( ! $membership_product && isset( $available_gateways['stripe'] )) {
- unset($available_gateways['stripe']);
- }
- return $available_gateways;
- }, 90);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement