I want to hide the billing address from the checkout page (not remove it) and make the billing address set for the first time when registered?
To allow display on the bill .pdf
I add this code:
<?php
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
unset($fields['billing']['billing_first_name']);
unset($fields['billing']['billing_last_name']);
unset($fields['billing']['billing_company']);
unset($fields['billing']['billing_address_1']);
unset($fields['billing']['billing_address_2']);
unset($fields['billing']['billing_city']);
unset($fields['billing']['billing_postcode']);
unset($fields['billing']['billing_country']);
unset($fields['billing']['billing_state']);
unset($fields['billing']['billing_phone']);
unset($fields['order']['order_comments']);
unset($fields['billing']['billing_address_2']);
unset($fields['billing']['billing_postcode']);
unset($fields['billing']['billing_company']);
unset($fields['billing']['billing_last_name']);
unset($fields['billing']['billing_email']);
unset($fields['billing']['billing_city']);
return $fields;
}
And by adding this code, the billing address wasn't added to the pdf bill
So which code shall I add or edit?
Thank you in advance.
First step: Make the billing address set for the first time when registered
1) You need to change WooCommerce setting for registration.
WooCommerce Settings > Account (tab):
2) Adding Billing fields in user registration My Account page:
Base: How to add custom fields in user registration on the "My Account" page
The customized code (copy that code in the function.php file of your active child theme or theme):
Second step: Hidding the billing address from the checkout whiteout remove it
You will need to use CSS targeting the billing block fields with
display: none !important;
rule.