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 11113 times.

Share your WooCommerce code snippets:

  • Get some recognition & link back to your site.


Submit | Browse

Most Recent woocommerce snippets

Most Viewed