Move location of billing email field to work with password managers.

Fixes #11016
This commit is contained in:
Mike Jolley 2016-11-25 11:32:42 +00:00
parent f67ffe4d89
commit eab41b37f7
3 changed files with 33 additions and 30 deletions

View File

@ -100,21 +100,23 @@ class WC_Checkout {
$this->checkout_fields['billing'] = WC()->countries->get_address_fields( $this->get_value( 'billing_country' ), 'billing_' );
$this->checkout_fields['shipping'] = WC()->countries->get_address_fields( $this->get_value( 'shipping_country' ), 'shipping_' );
if ( get_option( 'woocommerce_registration_generate_username' ) == 'no' ) {
if ( 'no' === get_option( 'woocommerce_registration_generate_username' ) ) {
$this->checkout_fields['account']['account_username'] = array(
'type' => 'text',
'label' => __( 'Account username', 'woocommerce' ),
'required' => true,
'placeholder' => esc_attr__( 'Username', 'woocommerce' ),
'type' => 'text',
'label' => __( 'Account username', 'woocommerce' ),
'required' => true,
'placeholder' => esc_attr__( 'Username', 'woocommerce' ),
'autocomplete' => 'username',
);
}
if ( get_option( 'woocommerce_registration_generate_password' ) == 'no' ) {
if ( 'no' === get_option( 'woocommerce_registration_generate_password' ) ) {
$this->checkout_fields['account']['account_password'] = array(
'type' => 'password',
'label' => __( 'Account password', 'woocommerce' ),
'required' => true,
'placeholder' => esc_attr__( 'Password', 'woocommerce' ),
'type' => 'password',
'label' => __( 'Account password', 'woocommerce' ),
'required' => true,
'placeholder' => esc_attr__( 'Password', 'woocommerce' ),
'autocomplete' => 'password',
);
}

View File

@ -1016,27 +1016,27 @@ class WC_Countries {
foreach ( $fields as $key => $value ) {
$keys = array_keys( $fields );
$address_fields[ $type . $key ] = $value;
}
// Add email and phone after company or last
if ( 'billing_' === $type && ( 'company' === $key || ( ! array_key_exists( 'company', $fields ) && end( $keys ) === $key ) ) ) {
$address_fields['billing_email'] = array(
'label' => __( 'Email address', 'woocommerce' ),
'required' => true,
'type' => 'email',
'class' => array( 'form-row-first' ),
'validate' => array( 'email' ),
'autocomplete' => 'email',
);
$address_fields['billing_phone'] = array(
'label' => __( 'Phone', 'woocommerce' ),
'required' => true,
'type' => 'tel',
'class' => array( 'form-row-last' ),
'clear' => true,
'validate' => array( 'phone' ),
'autocomplete' => 'tel',
);
}
// Add email and phone fields.
if ( 'billing_' === $type ) {
$address_fields['billing_phone'] = array(
'label' => __( 'Phone', 'woocommerce' ),
'required' => true,
'type' => 'tel',
'class' => array( 'form-row-first' ),
'validate' => array( 'phone' ),
'autocomplete' => 'tel',
);
$address_fields['billing_email'] = array(
'label' => __( 'Email address', 'woocommerce' ),
'required' => true,
'clear' => true,
'type' => 'email',
'class' => array( 'form-row-last' ),
'validate' => array( 'email' ),
'autocomplete' => 'no' === get_option( 'woocommerce_registration_generate_username' ) ? 'email' : 'email username',
);
}
$address_fields = apply_filters( 'woocommerce_' . $type . 'fields', $address_fields, $country );

View File

@ -185,6 +185,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woocommerce/wo
* New gallery on single product pages with better mobile support, PhotoSwipe and Zoom.
* Removed last order from customers part of the API due to performance concerns - use orders endpoint instead. Other order data on the endpoint is now transient cached.
* Use all paid statuses in $customer->get_total_spent().
* Move location of billing email field to work with password managers.
* CRUD - Optimised variable product sync. Upper/lower price meta is no longer stored, just the main prices, if a child has weight, and if a child has dimensions.
* CRUD - Removed WP_Query from up-sells.php and related.php and replaced with PHP foreach loop (since we already have the product IDs).