From 0b300b364871e416ec0e0891906244aff4a68bb9 Mon Sep 17 00:00:00 2001 From: David Stone Date: Tue, 24 Mar 2026 21:08:51 -0600 Subject: [PATCH] fix(tax): redesign universal tax as 'Apply to all countries' dropdown option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implements the maintainer's preferred approach from PR #277 review feedback: add an 'Apply to all countries' option to the country dropdown on the Tax Rates configuration page, rather than using new settings fields. Changes: - views/taxes/list.php: add '*' option at top of country dropdown - inc/functions/tax.php: handle '*' country as fallback in wu_get_applicable_tax_rates() — applies when no exact-country rates match - lang/ultimate-multisite.pot: add 'Apply to all countries' string, update line number references for 'Leave blank to apply to all' This approach is simpler, consistent with how state/city already use blank/wildcard to mean 'apply to all', and requires no new settings. Closes #426 --- inc/functions/tax.php | 14 ++++++++++++++ lang/ultimate-multisite.pot | 8 ++++++-- views/taxes/list.php | 4 ++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/inc/functions/tax.php b/inc/functions/tax.php index 1e833d5ac..4a56811e5 100644 --- a/inc/functions/tax.php +++ b/inc/functions/tax.php @@ -201,6 +201,20 @@ function wu_get_applicable_tax_rates($country, $tax_category = 'default', $state } } + /* + * If no country-specific rates matched, apply any rates configured + * with '*' (Apply to all countries) as a fallback. + */ + if (empty($results)) { + foreach ($tax_category['rates'] as $rate) { + if ('*' === $rate['country']) { + $rate['order'] = 1; + + $results[ $rate['id'] ] = $rate; + } + } + } + uasort($results, 'wu_sort_by_order'); return array_values($results); diff --git a/lang/ultimate-multisite.pot b/lang/ultimate-multisite.pot index 088d83443..35fb3b5b7 100644 --- a/lang/ultimate-multisite.pot +++ b/lang/ultimate-multisite.pot @@ -22513,8 +22513,12 @@ msgstr "" msgid "Loading Tax Rates..." msgstr "" -#: views/taxes/list.php:266 -#: views/taxes/list.php:281 +#: views/taxes/list.php:243 +msgid "Apply to all countries" +msgstr "" + +#: views/taxes/list.php:270 +#: views/taxes/list.php:285 msgid "Leave blank to apply to all" msgstr "" diff --git a/views/taxes/list.php b/views/taxes/list.php index d7213bb29..8fcfbc84e 100644 --- a/views/taxes/list.php +++ b/views/taxes/list.php @@ -239,6 +239,10 @@