get_option( 'account_details', [] ); } // Method 2: Direct property access (fallback) if ( empty( $accounts ) && isset( $gateway->account_details ) ) { $accounts = $gateway->account_details; } // Method 3: Get from WordPress options directly (last resort) if ( empty( $accounts ) ) { $gateway_settings = get_option( 'woocommerce_bacs_settings', [] ); if ( isset( $gateway_settings['account_details'] ) ) { $accounts = $gateway_settings['account_details']; } } if ( empty( $accounts ) || ! is_array( $accounts ) ) { return $channels; } // Convert accounts to channels foreach ( $accounts as $index => $account ) { if ( ! is_array( $account ) || empty( $account['account_name'] ) ) { continue; } $bank_name = $account['bank_name'] ?? ''; $account_name = $account['account_name'] ?? ''; $account_num = $account['account_number'] ?? ''; // Build channel title $title = $bank_name ? "{$bank_name} - {$account_name}" : $account_name; if ( $account_num ) { $title .= " ({$account_num})"; } $channels[] = [ 'id' => 'bacs_' . sanitize_title( $account_name . '_' . $index ), 'title' => $title, 'meta' => $account, ]; } return $channels; } /** * Detect custom channels from other gateways * * This is a placeholder for future gateway integrations. * Other plugins can hook into woonoow/payment_gateway_channels * to provide their own channel logic. */ public static function detect_custom_channels( array $channels, string $gateway_id, $gateway ): array { /** * Hook for third-party payment gateway channel detection * * Example for Stripe with multiple accounts: * * add_filter('woonoow/payment_gateway_channels', function($channels, $gateway_id, $gateway) { * if ($gateway_id === 'stripe') { * $accounts = get_option('stripe_connected_accounts', []); * foreach ($accounts as $account) { * $channels[] = [ * 'id' => 'stripe_' . $account['id'], * 'title' => $account['name'], * 'meta' => $account, * ]; * } * } * return $channels; * }, 30, 3); */ return $channels; } }