Skip to content
Advertisement

Remove “(optional)” text from checkout fields in Woocommerce 3.4+

I was previously using this answer to hide checkout fields based on chosen shipping method, it worked fine until an update (3.4.2 current version) I think not sure what has changed but it doesn’t work as intended anymore.

Previously when local pickup was chosen some fields were hidden and made optional and when delivery was chosen it would show those fields again all via dynamically without reloading the page.

Now it shows and hides the fields as required however, when delivery is chosen it is showing the correct fields marked as mandatory but also has the (optional) sign next to it and it makes it optional. See picture below.

enter image description here

Here’s my modified snipper below:

JavaScript

Any pointers would be much appreciated!

Advertisement

Answer

Update 2

To remove “(optional)” text from checkout fields labels introduced with Woocommerce release 3.4, just as it was before, you will need to add the following code:

JavaScript

Code goes in function.php file of your active child theme (or active theme). Tested and works in Woocommerce version 3.4+.

You could merge the included jQuery code with your existing jQuery code…

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement