Summary
Merchants using the MemberPress VAT add-on sometimes need to control the visibility and default behavior of the VAT Number field and Customer Type selector during checkout. Common requirements include always displaying the VAT Number field regardless of customer type selection, and defaulting the Customer Type to Business instead of Consumer to streamline VAT collection workflows.
This document provides tested CSS and PHP customizations to achieve both behaviors. The solutions address edge cases where conditional field display logic interferes with business requirements for specific tax jurisdictions or compliance workflows. These customizations are not available through standard MemberPress settings and require code implementation via the WPCode plugin or child theme functions.
Troubleshooting
Implementing VAT Field Visibility And Customer Type Customizations
The following implementation methods provide two distinct customization options that can be used independently or together. Option 1 forces the VAT Number field to always display and hides the Customer Type selector. Option 2 sets the default Customer Type selection to Business instead of Consumer.
Method 1: Using WPCode Plugin (Recommended)
- Navigate to Dashboard > Code Snippets > + Add Snippet.
- Click Add Your Custom Code (New Snippet).
- Enter a title such as “Force VAT Field Visibility and Default Business Type”.
- Set Code Type to PHP Snippet.
- Paste the complete customization code provided in the Customization Snippet section below.
- Set Location to Run Everywhere.
- Enable the Active toggle.
- Click Save Snippet.
- Clear all site cache (plugin cache, server cache, and CDN cache if applicable).
- Test checkout flow while logged out to verify the VAT Number field displays immediately and Customer Type defaults to Business.
Method 2: Using Child Theme Functions
- Access your site files via FTP or hosting file manager.
- Navigate to /wp-content/themes/[[CHILD_THEME_NAME]]/.
- Open the functions.php file for editing.
- Scroll to the end of the file and paste the complete customization code provided in the Customization Snippet section below.
- Save the file.
- Clear all site cache (plugin cache, server cache, and CDN cache if applicable).
- Test checkout flow while logged out to verify the VAT Number field displays immediately and Customer Type defaults to Business.
Customization Snippet
Add the following code block using either Method 1 or Method 2 above. Both Option 1 and Option 2 are included in this snippet. To disable either option, comment out the relevant section by adding // before each line in that section.
/**
* MemberPress - VAT Customer Type Customizations
*
* PURPOSE:
* - Option 1: Hide Customer Type field and always show VAT field.
* - Option 2: Set "Business" as the default Customer Type selection.
*
* HOW TO USE:
* - Keep both Option 1 and Option 2 enabled, or disable either by commenting it out.
* - Prefer adding this via a code snippets plugin (e.g., WPCode) or an mu-plugin.
*
* REQUIREMENTS:
* - MemberPress active.
*
* NOTES:
* - CSS selectors rely on current VAT add-on markup:
* .mepr_vat_customer_type_row and .mepr_vat_number_row
* - If markup changes in future versions, update selectors accordingly.
*/
// -------- Option 1: Hide Customer Type field and always show VAT field --------
function mepr_hide_customer_type_field() {
?>
<style>
.mepr_vat_customer_type_row { display: none !important; }
.mepr_vat_number_row { display: block !important; }
</style>
<?php
}
add_action( 'wp_head', 'mepr_hide_customer_type_field' );
// -------- Option 2: Set Business as default Customer Type selection ----------
/**
* Filter: mepr_vat_customer_type_default
* Expected return values: 'consumer' or 'business'
*/
function mepr_set_default_customer_type_business( $customer_type ) {
// If no customer type is set (first load) or detected as consumer, default to 'business'.
if ( empty( $customer_type ) || 'consumer' === $customer_type ) {
return 'business';
}
return $customer_type;
}
add_filter( 'mepr_vat_customer_type_default', 'mepr_set_default_customer_type_business' );
Understanding The Customization Options
1) VAT Number Field Only Shows After Customer Type Selection
By default, the MemberPress VAT add-on conditionally displays the VAT Number field based on the Customer Type selection. The field only appears after a customer selects Business from the Customer Type dropdown. This creates additional friction in the checkout process for businesses that primarily serve B2B customers or operate in jurisdictions where VAT collection is mandatory for all transactions.
How to Test/Fix: Option 1 in the customization snippet uses CSS to force the VAT Number field to display immediately on page load by setting .mepr_vat_number_row to display: block !important. It simultaneously hides the Customer Type selector by setting .mepr_vat_customer_type_row to display: none !important. This ensures customers see the VAT Number field without needing to interact with the Customer Type dropdown first. After implementing Option 1, test the checkout page while logged out and verify the VAT Number field is visible before any form interaction. If the field does not appear, clear all cache layers and check browser console for CSS conflicts with theme or other plugin styles.
2) Customer Type Defaults To Consumer Instead Of Business
The MemberPress VAT add-on defaults the Customer Type selection to Consumer. This creates unnecessary steps for merchants whose primary customer base consists of businesses rather than individual consumers. In B2B-focused scenarios or regions with mandatory VAT collection requirements, defaulting to Business streamlines the checkout experience and reduces form abandonment.
How to Test/Fix: Option 2 in the customization snippet uses the mepr_vat_customer_type_default filter to change the default Customer Type selection to Business. The filter function checks if the customer type value is empty or set to consumer, then returns business instead. This modification occurs before the checkout form renders, ensuring the Business option is pre-selected. If using Option 2 without Option 1, customers can still manually change the selection to Consumer if needed. After implementing Option 2, test the checkout page while logged out. Verify that the Customer Type dropdown shows Business as the selected option. If the Business option is not pre-selected, verify the filter name matches the exact hook used by your VAT add-on version. Clear all cache and test again.
3) CSS Customization Not Applying After Code Implementation
After adding the customization code, the VAT Number field may still not display or the Customer Type field may remain visible. This typically occurs when aggressive caching prevents the new CSS rules from loading, or when theme or plugin CSS specificity overrides the custom styles.
How to Test/Fix: First, clear all cache layers including WordPress cache plugins, server-side cache, and CDN cache. If using a page builder like Elementor or Divi, regenerate CSS files from the builder settings. Test the checkout page in a private browser window to bypass browser cache. If the customization still does not apply, use browser developer tools to inspect the VAT Number field element. Check if the .mepr_vat_number_row class is present and verify which CSS rules are being applied. If theme or plugin styles have higher specificity than the custom CSS, increase specificity by adding the !important declaration or by prefixing the selector with body or html. For example, change .mepr_vat_number_row { display: block !important; } to body .mepr_vat_number_row { display: block !important; }.
4) Filter Not Changing Default Customer Type Selection
After implementing Option 2, the Customer Type dropdown may still default to Consumer instead of Business. This occurs when the filter hook name does not match the exact hook provided by the installed VAT add-on version, or when another plugin or theme function hooks into the same filter with higher priority.
How to Test/Fix: Verify the exact filter hook name used by the VAT add-on by checking the add-on source code. Navigate to /wp-content/plugins/memberpress-vat/ and search for instances of apply_filters related to customer type defaults. Common variations include mepr_vat_customer_type_default, memberpress_vat_customer_type, or mpvat_customer_type_default. Update the filter name in the customization code to match the exact hook name found in the add-on files. If the correct hook is used but the filter still does not apply, add a third parameter to the add_filter call to set higher priority. Change add_filter( ‘mepr_vat_customer_type_default’, ‘mepr_set_default_customer_type_business’ ) to add_filter( ‘mepr_vat_customer_type_default’, ‘mepr_set_default_customer_type_business’, 99 ). This ensures the custom filter executes after other plugins or theme functions.
Important Limitations And Considerations
- The CSS selectors .mepr_vat_customer_type_row and .mepr_vat_number_row depend on current VAT add-on markup. Future add-on updates may change these class names, requiring selector updates in the customization code;
- Option 1 completely hides the Customer Type selector. Customers cannot toggle between Consumer and Business after implementation. If business logic requires customer type selection, use Option 2 only;
- Option 2 defaults to Business but allows customers to manually change selection if the Customer Type field remains visible. Combine with Option 1 to enforce Business-only checkout flow.
- These customizations affect frontend display and default form behavior only. VAT calculation logic remains controlled by MemberPress VAT add-on settings under Dashboard > MemberPress > Settings > Taxes;
- Aggressive cache plugins may prevent CSS changes from displaying immediately. Always clear cache after code implementation and test in private browser windows during verification;
- Child theme customizations will be lost if the parent theme is changed or if the child theme is deactivated. WPCode plugin implementation persists across theme changes and is recommended for long-term maintenance.
Public Facing Documentation / Additional References
Public Facing Documentation
- Setting Up VAT Taxes
- Configuring the Taxes Tab
- How to Set Up Popular Caching Plugins with MemberPress
- Using Your Browser’s Developer Tools
- Designing Pages with ReadyLaunchâ„¢










