Last active
January 6, 2021 22:48
-
-
Save assoscoupa/0d1dd6d1b1140e2708334a08a8c28957 to your computer and use it in GitHub Desktop.
WooCommerce How To Remove Address Line 2
This file contains hidden or 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 include the opening php tag. | |
// Place in your theme's functions.php file | |
// Set address 2 to not required | |
add_filter('woocommerce_checkout_fields', 'unrequire_address_2_checkout_fields' ); | |
function unrequire_address_2_checkout_fields( $fields ) { | |
$fields['billing']['billing_address_2']['required'] = false; | |
$fields['shipping']['shipping_address_2']['required'] = false; | |
return $fields; | |
} | |
// Remove billing address 2 from Checkout for WooCommerce | |
add_filter('cfw_get_billing_checkout_fields', 'remove_billing_address_2_checkout_fields', 100, 3); | |
function remove_billing_address_2_checkout_fields( $fields ) { | |
unset($fields['billing_address_2']); | |
return $fields; | |
} | |
// Remove shipping address 2 from Checkout for WooCommerce | |
add_filter('cfw_get_shipping_checkout_fields', 'remove_shipping_address_2_checkout_fields', 100, 3); | |
function remove_shipping_address_2_checkout_fields( $fields ) { | |
unset($fields['shipping_address_2']); | |
return $fields; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment