Skip to content

Instantly share code, notes, and snippets.

@jamesckemp
Created September 14, 2022 13:06
Show Gist options
  • Save jamesckemp/1f37f3c6fe901783aad23d937c86a8b3 to your computer and use it in GitHub Desktop.
Save jamesckemp/1f37f3c6fe901783aad23d937c86a8b3 to your computer and use it in GitHub Desktop.
<?php
/**
* Modify max length of first name field in WooCommerce.
*
* @param array $fields
*
* @return array
*/
function flux_modify_fname_field_length( $fields ) {
if ( isset( $fields['billing']['billing_first_name'] ) ) {
$fields['billing']['billing_first_name']['maxlength'] = 20;
}
if ( isset( $fields['shipping']['shipping_first_name'] ) ) {
$fields['shipping']['shipping_first_name']['maxlength'] = 20;
}
return $fields;
}
add_filter( 'woocommerce_checkout_fields', 'flux_modify_fname_field_length', 1001 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment