В данном случае при методе доставки «Самовивіз з Харкова» метод оплаты с идентификатором «liqpay-webplus» был выключен.
liqpay-webplus можно посмотреть в html коде в адинке в списке методов оплаты
<?php
function alter_shipping_methods($available_gateways){
global $woocommerce;
$chosen_titles = array();
$available_methods = $woocommerce->shipping->get_packages();
$chosen_rates = (isset($woocommerce->session)) ? $woocommerce->session->get('chosen_shipping_methods') : array();
foreach ($available_methods as $method) foreach ($chosen_rates as $chosen) {
if (isset($method['rates'][$chosen])) $chosen_titles[] = $method['rates'][$chosen]->label;
}
if (in_array('Самовивіз з Харкова', $chosen_titles)) {
unset($available_gateways['liqpay-webplus']);
}
return $available_gateways;
}
add_action('woocommerce_available_payment_gateways', 'alter_shipping_methods'); ?>
Альтернативный вариант
add_filter('woocommerce_available_payment_gateways', 'gv_tune_payment_methodes');
function gv_tune_payment_methodes($_available_gateways) {
$chosen_methods = WC()->session->get('chosen_shipping_methods');
$shipping_slug = explode( ':', $chosen_methods[0]);
switch ($shipping_slug[0]) {
case 'local_pickup':
unset($_available_gateways['bacs']);
unset($_available_gateways['cheque']);
unset($_available_gateways['liqpay-webplus']);
break;
case 'flat_rate':
unset($_available_gateways['cheque']);
break;
case 'free_shipping':
unset($_available_gateways['cod']);
break;
default:
break;
}
return $_available_gateways;
}