0
X
Add Snippet To Project
New Project
Add To Existing Project
add_filter( 'woocommerce_default_address_fields', 'wpturbo_add_custom_default_address_field' );
/**
* Add custom default address field to WooCommerce checkout form.
*
* @param array $fields The existing WooCommerce default address fields.
*
* @return array The modified default address fields.
*/
function wpturbo_add_custom_default_address_field( array $fields ): array {
$fields['wpturbo-has-business-gst-id'] = [
'label' => 'Are You a Registered Business With a GST ID?',
'class' => ['wpturbo-has-business-gst-id'],
'type' => 'checkbox',
];
return $fields;
}
add_filter('woocommerce_customer_meta_fields', 'wpturbo_add_address_field_to_admin_profile_page');
/**
* Add custom address field to WooCommerce admin user profile.
*
* @param array $admin_fields The existing WooCommerce customer meta fields.
*
* @return array The modified customer meta fields.
*/
function wpturbo_add_address_field_to_admin_profile_page( array $admin_fields ): array {
$admin_fields['billing']['fields']['billing_wpturbo-has-business-gst-id'] = [
'label' => 'Are You a Registered Business With a GST ID?',
'description' => '',
];
return $admin_fields;
}