If you are using the “WooCommerce EU/UK VAT Compliance (Premium)” by “David Anderson” to add the VAT field on the checkout page and it is not displaying then this article will help you to display that field on the CartFlows Checkout field.
The VAT field is used to add the VAT number or the VAT amount on the checkout page on the WooCommerce Platform.
This VAT field is not required to all of the stores or countries but only required by the European countries and any other to force the country’s rules and regulations for better compliance.
While using “WooCommerce EU/UK VAT Compliance (Premium)”, configure it completely and check that the VAT field is getting displayed on the default checkout of WooCommerce.
If that field is not displayed on the default checkout page of WooCommerce then it will not be displayed on the CartFlows Checkout page. So, to make it work with CartFlows, it is mandatory that the VAT field should be displayed on the default WooCommerce Checkout page.
The “WooCommerce EU/UK VAT Compliance (Premium)” plugin adds an input field on the checkout page. The label of that field will be the same that you have set from that plugin’s setting.
If that field is displayed on the default checkout page of WooCommerce and not on the CartFlows page, then this is because CartFlows modifies the checkout fields including the billing and shipping fields with our own custom field editor and as per the design of the checkout page.
These modifications are made using the default WooCommerce actions and filters. Due to these modifications, the priorities of those fields are changed and thus any other custom field added by the third-party plugin may or may not be displayed on the CartFlows Checkout page.
To display this field, the plugin “WooCommerce EU/UK VAT Compliance (Premium)“ has provided a filter to change the location of that field. So that we can decide where else we have to display the field, such as after billing fields, or after shipping fields, or even after the checkout form, etc etc.
Below is the code using which you can easily display the VAT field on the CartFlows checkout page.
add_filter( 'wc_eu_vat_number_position', 'eu_change_vat_number_position', 10, 1 );
/**
* Function to change the position of VAT field only for the CartFlows checkout page.
*
* @param $current_page current visited page
* @return $current_page current page.
*/
function eu_change_vat_number_position( $position ){
/* Get global post object */
global $post;
/* Get current post type */
$post_type = get_post_type();
/* Check the current type of the page */
$is_checkout = get_post_meta( $post->ID, 'wcf-step-type', true );
/* Change position only of the CartFlows checkout page */
if( 'cartflows_step' == $post_type && 'checkout' === $is_checkout){
$position = 'woocommerce_after_order_notes';
}
return $position;
}
Note: Add the above filter to your child theme’s functions.php, here’s an article to help you Add Custom code.