private function get_default_method($available_methods, $current_chosen_method = false)
{
if (!empty($available_methods)) {
if (!empty($current_chosen_method)) {
if (isset($available_methods[$current_chosen_method])) {
return $available_methods[$current_chosen_method]->id;
} else {
foreach ($available_methods as $method_key => $method) {
if (strpos($method->id, $current_chosen_method) === 0) {
return $method->id;
}
}
}
}
return current($available_methods)->id;
}
return '';
}