Ensure is pui payment method before custom checkout validation

This commit is contained in:
dinamiko 2022-05-20 12:08:33 +02:00
parent 58a53af41e
commit 98e356da17

View file

@ -317,6 +317,11 @@ class PayUponInvoice {
add_action(
'woocommerce_after_checkout_validation',
function( array $fields, WP_Error $errors ) {
$payment_method = filter_input( INPUT_POST, 'payment_method', FILTER_SANITIZE_STRING );
if ( PayUponInvoiceGateway::ID !== $payment_method ) {
return;
}
if ( 'DE' !== $fields['billing_country'] ) {
$errors->add( 'validation', __( 'Billing country not available.', 'woocommerce-paypal-payments' ) );
}