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:
parent
8dee94a0ed
commit
7b0b6e3db4
|
@ -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 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue