Usual method for checkout fields in WooCommerce does not work [duplicate]

This question already has answers here: How to remove all Woocommerce checkout billing fields without errors (1 answer) Why are some checkout hooks not working in WooCommerce? (1 answer) Closed yesterday. My shop is a "name your price" only to deliver files to the users of my free tutorials. So checkout page has to be as light as possible, removing those useless fields. I am using the snippet below that seems to have no effect. It is executed via a snippet plugin. The fields remain. Step 2 : when it works, I will display the email fields only if a donation is made (so when the price is greater than 0). Note that I added just echo "Download"; to be sure that the code is executed, and it is... I tested 'required' argument set to false, to see if it change something, but it didn't work. add_filter( 'woocommerce_checkout_fields' , 'custom_remove_woo_checkout_fields' ); function custom_remove_woo_checkout_fields( $fields ) { echo "Download"; // Just for testing // 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']); // remove billing fields required $fields['billing']['billing_first_name']['required'] = false; $fields['billing']['billing_last_name']['required'] = false; $fields['billing']['billing_company']['required'] = false; $fields['billing']['billing_address_1']['required'] = false; $fields['billing']['billing_address_2']['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_phone']['required'] = false; $fields['billing']['billing_email']['required'] = false; // remove shipping fields required $fields['shipping']['shipping_first_name']['required'] = false; $fields['shipping']['shipping_last_name']['required'] = false; $fields['shipping']['shipping_company']['required'] = false; $fields['shipping']['shipping_address_1']['required'] = false; $fields['shipping']['shipping_address_2']['required'] = false; $fields['shipping']['shipping_city']['required'] = false; $fields['shipping']['shipping_postcode']['required'] = false; $fields['shipping']['shipping_country']['required'] = false; $fields['shipping']['shipping_state']['required'] = false; $fields['billing']['billing_first_name']['required'] = false; return $fields; }

Comment (0)

You’ll be in good company