Forked from ipokkel/unset-and-hide-billing-state-field.php
Last active
January 4, 2021 12:50
-
-
Save femiyb/395e44ecf870ef58803e52c1bd1872ca to your computer and use it in GitHub Desktop.
PMPro - Remove state from required billing fields and hide it the state field.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // Do NOT copy this line | |
/* Copy from below this line */ | |
/* | |
Remove state from required billing fields and hide it the state field. | |
*/ | |
// Unset state | |
add_action( 'pmpro_required_billing_fields', 'my_pmpro_required_billing_fields' ); | |
function my_pmpro_required_billing_fields( $fields ) { | |
if ( is_array( $fields ) ) { | |
// unset( $fields['bfirstname'] ); | |
// unset( $fields['blastname'] ); | |
// unset( $fields['baddress1'] ); | |
// unset( $fields['bcity'] ); | |
unset( $fields['bstate'] ); | |
// unset( $fields['bcountry'] ); | |
// unset( $fields['bzipcode'] ); | |
unset( $fields['bphone'] ); | |
// unset( $fields['bemail'] ); | |
// unset( $fields['bconfirmemail'] ); | |
} | |
return $fields; | |
} | |
/* | |
// Hide field by adding CSS to the page head. | |
add_action( 'wp_head', 'wp_head_hide_billing_state_field' ); | |
function wp_head_hide_billing_state_field() { | |
global $pmpro_pages; | |
if ( empty( $pmpro_pages ) || ( ! is_page( $pmpro_pages['checkout'] ) && ! is_page( $pmpro_pages['billing'] ) ) ) { | |
return; | |
} | |
?> | |
<style> | |
div.pmpro_checkout-field-bstate { | |
display: none; | |
} | |
</style> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment