I've got the following function that modifies the checkout fields in WooCommerce. The code works fine in PHP 7.0 but after upgrading to 7.2 the checkout page just displays a white screen.
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
$fields['billing']['billing_phone']['label'] = 'Mobile number';
$fields['billing']['billing_address_2']['label'] = ' ';
$fields['billing']['billing_first_name']['class'] = '';
$fields['billing']['billing_last_name']['class'] = '';
$fields['shipping']['shipping_first_name']['class'] = '';
$fields['shipping']['shipping_last_name']['class'] = '';
return $fields;
}
If I comment out some of the $fields[ ...
lines the page works again, however it seems to be random which ones I comment out to make it work!
First of all: Why does this upset PHP 7.2? I'd really like to understand why this breaks the page.
Second: How can I make this customisation work in PHP 7.2?
-
FYI: My testing environment only has the WooCommerce plugin activated and is using the Twenty Seventeen theme