I understand that you can add custom fields on the checkout page of WooCommerce, but what I want to show before the billing details are the account fields, which are already existing as written in the documentation. These fields are named:
account_username
account_password
account_password-2
But they are not shown by default. I only managed to make them visible by putting them at the top of the list in the function for reordering the billing fields like this in my theme's function.php
like this
add_filter("woocommerce_checkout_fields", "order_fields");
function order_fields($fields) {
$order = array(
"account_username",
"account_password",
"account_password-2",
"billing_first_name",
"billing_last_name",
// other billing fields go here
);
foreach($order as $field)
{
$ordered_fields[$field] = $fields["billing"][$field];
}
$fields["billing"] = $ordered_fields;
return $fields;
}
This works fine with the functionality of creating an account while checking out, but I am having troubles with modifying its label and placeholder. This is what I tried to do:
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
$fields['account']['account_username']['label'] = '* Username: ';
$fields['account']['account_username']['placeholder'] = 'Enter username here...';
}
But it wouldn't let me change the labels and placeholder of the fields so I was thinking that maybe it has something to do with how I am displaying it and/or how I am modifying them.
Ideas, anyone? Thanks in advance.