I have some e-commerce website where the customer billing address is predefined on the back-end.
I need to set the “Billing Address” fields as ‘readonly’ to avoid the customer to replace the information placed there… but i don´t know how/where to do it…
Is it possible?
Put following code in your theme’s “function.php” file.
This function checks if the address fields have value (i.e. if the address is specified), and if it has value, makes the field/s readonly. Else keeps the fields open to add data for user.
Hope this helps.
You have not specified which form you want to customize making the billing address fields read-only. Normally the billing address fields appear on two types of forms on a WooCommerce site:
If your case is the first one, then zipkundan’s answer is the best one. But if your case is the second one, then copy and paste the following code to your active theme’s (or child theme if any) functions.php file:
The above code will make the following fields read-only:
Array keys for other form fields on the same page are as follows:
Additionally, you can make the read-only fields appear slightly faded out. So, add the following CSS to your theme’s style.css
this solves the problem
This one worked for me.
https://www.sitekickr.com/snippets/woocommerce/make-checkout-field-read