Barusan saya coba kodenya, tapi COD nya masih nampil di kurir lain nih.
Tapi saya ada kode lain yang work. Ini kodenya:
add_filter( ‘woocommerce_available_payment_gateways’, ‘filter_available_payment_gateways’);
function filter_available_payment_gateways( $available_gateways ) {
if ( ! ( is_checkout_pay_page() ) ) {
$gateways_to_disable = array(‘cod’);
$shipping_methods = array( ‘pok-SAP-0′,’pok-SAP-1′,’pok-jne-0′,’pok-jne-1′,’pok-jne-2′,’pok-jne-3′,’pok-jne-4′,’pok-jne-5′,’pok-jne-6′,’pok-jne-7′,’pok-jne-8′,’pok-jne-9′,’pok-jne-10′,’pok-jne-11′,’pok-jne-12′,’pok-jne-13′,’pok-jne-14′,’pok-jne-15′,’pok-jne-16′,’pok-jne-17′,’pok-jne-18′,’pok-jne-19′,’pok-jne-20′,’pok-jne-21′,’pok-jne-22′,’pok-jne-23′,’pok-jne-24′,’pok-jne-25′,’pok-jne-26′,’pok-jne-27′,’pok-jne-28′,’pok-jne-29′,’pok-jne-30′,’pok-jne-31′,’pok-jne-32′,’pok-jne-33′,’pok-jne-34′,’pok-sicepat-0′,’pok-sicepat-1′,’pok-sicepat-2′,’pok-sicepat-3′,’pok-sicepat-4′,’pok-sicepat-5′,’pok-sicepat-6′,’pok-sicepat-7′,’pok-sicepat-8′,’pok-sicepat-9′,’pok-sicepat-10’ );
$disable_gateways = false;
// Check if we need to disable gateways
foreach ( $shipping_methods as $shipping_method ) {
if ( strpos( WC()->session->get( ‘chosen_shipping_methods’ )[0], $shipping_method ) !== false ) $disable_gateways = true;
}
// If so, disable the gateways
if ( $disable_gateways ) {
foreach ( $available_gateways as $id => $gateway ) {
if ( in_array( $id, $gateways_to_disable ) ) {
unset( $available_gateways[$id] );
}
}
}
return $available_gateways;
}
else { return $available_gateways;
}
}
Mohon dibantu supaya lebih efisien. Terimakasih!