how to remove payment link in invoice woocommerce code example
Example: how to remove payment link in invoice woocommerce
add_filter( 'woocommerce_available_payment_gateways', 'conditionally_hide_payment_gateways', 100, 1 );
function conditionally_hide_payment_gateways( $available_gateways ) {
if( is_wc_endpoint_url( 'order-pay' ) ) {
$order = wc_get_order( get_query_var('order-pay') );
foreach( $available_gateways as $gateways_id => $gateways ){
if( $gateways_id !== 'paypal' && $order->has_status('pending') ) {
unset($available_gateways[$gateways_id]);
}
}
}
elseif( is_checkout() && ! is_wc_endpoint_url() ) {
if( isset($available_gateways['paypal']) ) {
unset($available_gateways['paypal']);
}
}
return $available_gateways;
}