Skip to content

Instantly share code, notes, and snippets.

@clifgriffin
Last active October 10, 2023 20:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clifgriffin/818a5ac1e8809e0ad8a4cf079e2590d4 to your computer and use it in GitHub Desktop.
Save clifgriffin/818a5ac1e8809e0ad8a4cf079e2590d4 to your computer and use it in GitHub Desktop.
Remove billing address fields for digital orders in Checkout for WooCommerce
<?php
// Do NOT include the opening php tag.
// Place in your theme's functions.php file
add_filter( 'cfw_get_billing_checkout_fields', 'remove_checkout_fields', 100 );
function remove_checkout_fields( $fields ) {
unset( $fields['billing_company'] );
unset( $fields['billing_city'] );
unset( $fields['billing_postcode'] );
unset( $fields['billing_country'] );
unset( $fields['billing_state'] );
unset( $fields['billing_address_1'] );
unset( $fields['billing_address_2'] );
return $fields;
}
// Set billing address fields to not required
add_filter( 'woocommerce_checkout_fields', 'unrequire_checkout_fields' );
function unrequire_checkout_fields( $fields ) {
$fields['billing']['billing_company']['required'] = false;
$fields['billing']['billing_city']['required'] = false;
$fields['billing']['billing_postcode']['required'] = false;
$fields['billing']['billing_country']['required'] = false;
$fields['billing']['billing_state']['required'] = false;
$fields['billing']['billing_address_1']['required'] = false;
$fields['billing']['billing_address_2']['required'] = false;
return $fields;
}
@deta19
Copy link

deta19 commented Oct 10, 2023

nice stuff. Thank you!

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