Only add '(optional)' to the billing_address_2 placeholder | #25510

This commit is contained in:
barryhughes 2021-02-15 13:49:28 -08:00
parent 7a71258257
commit 1bd9a7e939
1 changed files with 7 additions and 1 deletions

View File

@ -658,10 +658,14 @@ class WC_Countries {
* @return array * @return array
*/ */
public function get_default_address_fields() { public function get_default_address_fields() {
$address_2_label = __( 'Apartment, suite, unit, etc.', 'woocommerce' );
// If necessary, append '(optional)' to the placeholder: we don't need to worry about the
// label, though, as woocommerce_form_field() takes care of that.
if ( 'optional' === get_option( 'woocommerce_checkout_address_2_field', 'optional' ) ) { if ( 'optional' === get_option( 'woocommerce_checkout_address_2_field', 'optional' ) ) {
$address_2_placeholder = __( 'Apartment, suite, unit, etc. (optional)', 'woocommerce' ); $address_2_placeholder = __( 'Apartment, suite, unit, etc. (optional)', 'woocommerce' );
} else { } else {
$address_2_placeholder = __( 'Apartment, suite, unit, etc.', 'woocommerce' ); $address_2_placeholder = $address_2_label;
} }
$fields = array( $fields = array(
@ -704,6 +708,8 @@ class WC_Countries {
'priority' => 50, 'priority' => 50,
), ),
'address_2' => array( 'address_2' => array(
'label' => esc_attr( $address_2_label ),
'label_class' => array( 'screen-reader-text' ),
'placeholder' => esc_attr( $address_2_placeholder ), 'placeholder' => esc_attr( $address_2_placeholder ),
'class' => array( 'form-row-wide', 'address-field' ), 'class' => array( 'form-row-wide', 'address-field' ),
'autocomplete' => 'address-line2', 'autocomplete' => 'address-line2',