Learn in this tutorial how to remove the last name field from Easy Digital Downloads (EDD) checkout using code.
Easy Digital Downloads displays by default 3 fields in the “Personal Information” section of the checkout page:
- Mailing Address
- First name
- Last name
But what happens if you prefer not to show the last name field?
A possible solution would be to hide it with a bit of CSS, but you know that I always encourage you to remove the elements you don’t need from the root, so you avoid loading them on the page.
So in this tutorial you are going to see how to remove the last name field taking advantage of the Easy Digital Downloads hooks.
Snippet to hide the last name field at checkout in Easy Digital Downloads
Add the following code at the end of functions.php or in your functionality plugin:
With this code you are removing the default “Personal Information” form to load a custom one.
In this case, you remove the fragment that carries the last name field.
But you can also edit other elements of the form. For example, you can remove the legend that appears just below each field, with this variation:
This would be the result:
You could go further and leave only the placeholders (the inner text) of the fields, but for accessibility issues I recommend that you don’t remove the labels (the top text).
Do you want to remove the last name field from Easy Digital Downloads checkout? Now you know how to do it easily using code.
Any questions? Let me know in the comments.
And if you want to give me any suggestion for future tutorials, leave it in the contact form. Advantages of being a subscriber. 😉