问题
My main goal is to change the "create an account" checkout to register the email as a username. The easy way I thought of was changing "Account Password" from password to email to override user_login
.
However, I can't seem to find where the "Password" text box is coming from. I know that this the code I needed under form-billing.php
, but I am unsure how only password is showing considering there's a for-loop
.
<?php foreach ( $checkout->checkout_fields['account'] as $key => $field ) : ?>
<?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>
<?php endforeach; ?>
Any advice is appreciated.
回答1:
here is file directory path of password and code:--
plugins\woocommerce\includes\class-wc-checkout.php
if ( get_option( 'woocommerce_registration_generate_password' ) == 'no' ) {
$this->checkout_fields['account']['account_password'] = array(
'type' => 'password',
'label' => __( 'Account password', 'woocommerce' ),
'required' => true,
'placeholder' => _x( 'Password', 'placeholder', 'woocommerce' )
);
}
回答2:
Or you can put this code in your function.php this way, an update doesn't overide it :
add_filter( 'woocommerce_checkout_fields' , 'custom_wc_checkout_fields' );
function custom_wc_checkout_fields( $fields ) {
$fields['account']['account_password']['placeholder'] = '';
return $fields;
}
来源:https://stackoverflow.com/questions/38071216/woocommerce-account-password-field-in-checkout-page