WooCommerce Make a checkout field read only

Add this snippet to your functions.php file to make a checkout field read only (applies readonly attribute).

This example applies to the billing first and last name, but you can apply it to any checkout field.
add_filter('woocommerce_billing_fields', 'my_woocommerce_billing_fields');
function my_woocommerce_billing_fields($fields)

   $fields['billing_first_name']['custom_attributes'] = array('readonly'=>'readonly');
   $fields['billing_last_name']['custom_attributes'] = array('readonly'=>'readonly');
   return $fields;

Posted by
Snippet Viewed 704 times.

Share your WooCommerce code snippets:

  • Get some recognition & a link back to your site.
  • Create your own code library.
  • Help your fellow developers, as they have helped you.
Submit | Browse

Most Recent woocommerce snippets

Most Viewed

The FitDesk Under Desk Elliptical