Filter enhancement

add field key to 'woocommerce_checkout_required_field_notice' filter. Currently if we want to hook any field we can only hooked on field's label. This is not good because field can have duplicate label. And field label can hae many variation because of translations. We need to add field key to the filter so we can hook on it instead.
This commit is contained in:
erikdemarco 2021-12-14 17:09:12 +07:00 committed by GitHub
parent 8dee94a0ed
commit 7b0b6e3db4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -831,7 +831,7 @@ class WC_Checkout {
if ( $validate_fieldset && $required && '' === $data[ $key ] ) {
/* translators: %s: field name */
$errors->add( $key . '_required', apply_filters( 'woocommerce_checkout_required_field_notice', sprintf( __( '%s is a required field.', 'woocommerce' ), '<strong>' . esc_html( $field_label ) . '</strong>' ), $field_label ), array( 'id' => $key ) );
$errors->add( $key . '_required', apply_filters( 'woocommerce_checkout_required_field_notice', sprintf( __( '%s is a required field.', 'woocommerce' ), '<strong>' . esc_html( $field_label ) . '</strong>' ), $field_label, $key ), array( 'id' => $key ) );
}
}
}