Update 3.32

Permalink 1) Use of the hook "woocommerce_checkout_fields" from version 3.32

Up to version 3.31 of German Market, the woocommerce_before_order_notes hook was used to output the field for entering the VAT number on the shortcode-based checkout page.

For better compatibility with third-party plugins and browsers, this has been changed in version 3.32 so that the checkout page is updated correctly after the input has been changed and the VAT number has been validated. The hook woocommerce_checkout_fields is now used.

The changes in version 3.32 are not relevant for you if you use the block-based checkout.

If you use the shortcode-based checkout, the changes are not relevant for you if you do not use a plugin or code snippet to influence the fields on the checkout page.

Permalink 2) If you are already using a code snippet to customize the output

If you are already using a code snippet to customize the output, the field for entering the VAT number will probably be displayed twice on the shortcode-based checkout after the update to version 3.32. You now have two options to ensure that the field only appears once again:

– Remove your previous customization (recommended) or
– Use the following code snippet to remove the new output from version 3.32:

add_action( 'after_setup_theme', function() {
	if ( function_exists( 'wcvat_woocommerce_add_vat_field_to_checkout_fields' ) ) {
		remove_filter( 'woocommerce_checkout_fields', 'wcvat_woocommerce_add_vat_field_to_checkout_fields', 50, 1 );
	}
});

Permalink 3) If you are currently using a plugin to output the field

Even if you have been using a plugin to influence the fields on the checkout page, the field for entering the VAT number may be displayed twice. If you want to continue to have the field output by the plugin you are using, use the following code snippet to remove the output from version 3.32:

add_action( 'after_setup_theme', function() {
	if ( function_exists( 'wcvat_woocommerce_add_vat_field_to_checkout_fields' ) ) {
		remove_filter( 'woocommerce_checkout_fields', 'wcvat_woocommerce_add_vat_field_to_checkout_fields', 50, 1 );
	}
});

If you have added the field with your plugin, you must now ensure that the enclosing paragraph ( <p> tag) has the CSS class update_totals_on_change. To do this, you should find settings for the field in your plugin (e.g. “Wrapper Class” or similar). This is the only way to ensure that WooCommerce updates the checkout page correctly after a VAT number has been entered and validated.

Permalink 4) No field with version 3.32 is output

If the field for entering the VAT number is no longer displayed on the shortcode-based checkout page as of version 3.32, you are probably using a customization that hides the Order notes. This customization could be such a code snippet:

add_filter('woocommerce_enable_order_notes_field', '__return_false');

To display the field for entering the VAT number, remove your previous code snippet. The field for entering the VAT number is now displayed. The Order comments are now also displayed, which you wanted to prevent with your previous code snippet. Now use this code snippet to hide the order comments again:

add_filter( 'woocommerce_checkout_fields' , function( $fields ) {

    if ( isset( $fields[ 'order' ] ) && isset( $fields[ 'order' ][ 'order_comments' ] ) ) {
		unset( $fields[ 'order' ][ 'order_comments' ] );
	}
	return $fields;
});

The field for entering the VAT number is now displayed, but the Order notes field is hidden.

Permalink 5) Customize the output of the field with version 3.32

If points 2) and 3) do not apply to you and you want to adjust the output of the field, you can use the filters wcvat_field_section and wcvat_field_priority. For example, if you want to output the field for entering the VAT number after the billing country, you can use this code snippet:

add_filter( 'wcvat_field_section', function( $order_or_billing ) {
	return 'billing';
});

add_filter( 'wcvat_field_priority', function( $prio ) {
	return 40;
});