Closed Mvgnu closed 2 years ago
I was able to fix this by deactivating
add_filter( 'woocommerce_checkout_fields', array( __CLASS__, 'checkout_fields' ), 10, 1 );
add_action( 'woocommerce_checkout_update_order_meta', array( __CLASS__, 'checkout_update_order_meta' ), 10, 2 );
in pronamic-ideal/vendor/wp-pay-extensions/woocommerce/src/Extension.php
Hello @Mvgnu, I wanted to see if we can improve on this so you don't have to make any changes in our plugin source files on future plugin updates. However, the below filter seems to work perfectly fine (also with different filter priorities) and I was unable to reproduce the issue. If you have any further details you can share to reproduce the issue, please let us know.
add_filter( 'woocommerce_checkout_fields', 'pronamic_woocommerce_checkout_fields', 10, 1 );
function pronamic_woocommerce_checkout_fields( $fields ) {
// Check billing fields.
if ( ! array_key_exists( 'billing', $fields ) ) {
return $fields;
}
// Check billing last name field.
if ( ! array_key_exists( 'billing_last_name', $fields['billing'] ) ) {
return $fields;
}
// Make last name optional.
if ( is_array( $fields['billing']['billing_last_name'] ) ) {
$fields['billing']['billing_last_name']['required'] = false;
}
return $fields;
}
Woocommerce checkout fields being made optional is being overwritten by the pronamic pay Wordpress plugin, making it impossible to checkout when said fields are removed and impossible to make them optional when displayed but required set to false through filters in the fuctions.php.