Created
June 25, 2025 07:53
-
-
Save xlplugins/c029737cd94a350b83c95e2b325b03f5 to your computer and use it in GitHub Desktop.
display Tax and vat conditionally
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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