Hiding and customising address fields on Checkout
This example explains how you can hide a field on Firmhouse Checkout with some custom JavaScript.
You can hide or customise address fields on Firmhouse Checkout with some custom JavaScript in your Checkout settings. Most commonly this is used for customising the address fields to your needs.
For example, some of our users want to only have a single address line, without separate house number.
The only prerequisite is that your project is running on a custom domain.
To customise something on Firmhouse Checkout, you can add custom code to Checkout > Preferences > Custom code > Body field.
The following example code does two things:
- It hides the house number field.
- It sets the address field to be limited to 35 characters in your customer's browser.
Sample code
<script>
var house_number_field = document.getElementById("subscription_house_number");
if (house_number_field) {
var house_number_field_wrapper = house_number_field.parentNode.parentNode.parentNode.parentNode;
house_number_field_wrapper.remove();
}
var address_field = document.getElementById("subscription_address");
if (address_field) {
address_field.setAttribute("maxlength", "35");
}
</script>