Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jebaird/6870bc32a5ddb6f5cb3f to your computer and use it in GitHub Desktop.
Save jebaird/6870bc32a5ddb6f5cb3f to your computer and use it in GitHub Desktop.
Hides all but the Australian states in the state field for ONTRApages. Only works for chrome and firefox, ie doesn't support hiding options via css. Just drop this gist into the custom header code textarea in the settings tab
<style>
/* hide all options in the state field */
select[name="state"] option {
display: none;
}
/* target the states we want to show via the value attribute */
select[name="state"] option[value="ACT"],
select[name="state"] option[value="NSW"],
select[name="state"] option[value="VIC"],
select[name="state"] option[value="QLD"],
select[name="state"] option[value="AU_NT"],
select[name="state"] option[value="AU_WA"],
select[name="state"] option[value="SA"],
select[name="state"] option[value="TAS"],
select[name="state"] option[value=""],
select[name="state"] option[value="_NOTLISTED_"],
select[name="state"] option[value="ACT"] {
display: block;
}
</style>
@ONTRAPORT-Frank
Copy link

Kevin Eales Monroe mentioned to me that a similar block of CSS is needed to set the states for the billing country as well:

<style>
    /* hide all options in the state field */
    select[name="billing_state"] option {
        display: none;
    }
    /* target the states we want to show via the value attribute */
    select[name="billing_state"] option[value="ACT"],
    select[name="billing_state"] option[value="NSW"],
    select[name="billing_state"] option[value="VIC"],
    select[name="billing_state"] option[value="QLD"],
    select[name="billing_state"] option[value="AU_NT"],
    select[name="billing_state"] option[value="AU_WA"],
    select[name="billing_state"] option[value="SA"],
    select[name="billing_state"] option[value="TAS"],
    select[name="billing_state"] option[value=""],
    select[name="billing_state"] option[value="_NOTLISTED_"],
    select[name="billing_state"] option[value="ACT"] {
        display: block;
    }
</style>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment