-
-
Save cryptexvinci/75ba823a824b29e04a08ee7893fc0ee5 to your computer and use it in GitHub Desktop.
<?php | |
add_filter( 'woocommerce_checkout_fields' , 'custom_remove_woo_checkout_fields' ); | |
function custom_remove_woo_checkout_fields( $fields ) { | |
// remove billing 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['billing']['billing_email']); | |
// remove shipping fields | |
unset($fields['shipping']['shipping_first_name']); | |
unset($fields['shipping']['shipping_last_name']); | |
unset($fields['shipping']['shipping_company']); | |
unset($fields['shipping']['shipping_address_1']); | |
unset($fields['shipping']['shipping_address_2']); | |
unset($fields['shipping']['shipping_city']); | |
unset($fields['shipping']['shipping_postcode']); | |
unset($fields['shipping']['shipping_country']); | |
unset($fields['shipping']['shipping_state']); | |
// remove order comment fields | |
unset($fields['order']['order_comments']); | |
return $fields; | |
} |
@adoWEB-code https://www.templatemonster.com/help/woocommerce-how-to-remove-checkout-fields.html
It's placed in your theme's functions file
Or the plugin Snippets
When all fields are unset, the paypal paymentvtype does not work for logged in users. It ops the paypal login page then immediately closes it. Some of the paypal javascript does not work either. Help
Thank You Bro
the most valuable update here could be I think that you need to set priority to 9999 to the hook because we want to run it as late as possible. The code will be. That helped me a lot, 'cause billing_address_2
and billing_first_name
fields were not hidden until I set this priority. Hope this helps someone 😉
add_filter( 'woocommerce_checkout_fields' , 'custom_remove_woo_checkout_fields', 9999 );
It works for me, with or without country field.