Skip to content

Instantly share code, notes, and snippets.

@xlplugins
Created June 25, 2025 07:53
Show Gist options
  • Save xlplugins/c029737cd94a350b83c95e2b325b03f5 to your computer and use it in GitHub Desktop.
Save xlplugins/c029737cd94a350b83c95e2b325b03f5 to your computer and use it in GitHub Desktop.
display Tax and vat conditionally
add_filter( 'woocommerce_countries_tax_or_vat', function( $label ) {
$country = '';
// Try to get customer's country from session
if ( WC()->customer ) {
$country = WC()->customer->get_taxable_address()[0];
}
// Fallback to store base country if no customer country yet (e.g., first visit)
if ( empty( $country ) ) {
$country = WC()->countries->get_base_country();
}
return strtoupper( $country ) === 'US' ? __( 'Tax', 'woocommerce' ) : $label;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment