feat(tax): implement universal tax as 'Apply to all countries' option in Tax Rates page#456
Conversation
Adds unit tests for the '*' country wildcard fallback behavior in wu_get_applicable_tax_rates(), covering: - Wildcard rate returned as fallback when no country-specific match - Per-country rates take precedence over wildcard rates - Wildcard not returned when a country-specific rate matches - Wildcard applies to any unmatched country - Empty result when no match and no wildcard configured The feature itself (dropdown option + fallback logic + POT string) was already implemented in views/taxes/list.php, inc/functions/tax.php, and lang/ultimate-multisite.pot. Closes #455
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔨 Build Complete - Ready for Testing!📦 Download Build Artifact (Recommended)Download the zip build, upload to WordPress and test:
🌐 Test in WordPress Playground (Very Experimental)Click the link below to instantly test this PR in your browser - no installation needed! Login credentials: |
Summary
Implements the 'Apply to all countries' universal tax fallback feature requested in issue #455.
What was already implemented
After reviewing the codebase, the core feature was already present:
views/taxes/list.php— Country dropdown already includes<option value="*">Apply to all countries</option>as the first optioninc/functions/tax.php—wu_get_applicable_tax_rates()already has fallback logic: when no country-specific rate matches, any rate withcountry='*'is applied as a universal fallbacklang/ultimate-multisite.pot— "Apply to all countries" string already present at line 22517This is the correct dropdown-option approach requested by the maintainer (not the separate settings toggle approach from closed PR #277).
What this PR adds
Tests (
tests/WP_Ultimo/Functions/Tax_Functions_Test.php) — 5 new test cases covering the'*'wildcard country behavior:test_get_applicable_tax_rates_returns_wildcard_as_fallback— wildcard rate returned when no country-specific matchtest_get_applicable_tax_rates_country_specific_takes_precedence_over_wildcard— per-country rates take precedencetest_get_applicable_tax_rates_wildcard_not_returned_when_country_matches— wildcard excluded when country matchestest_get_applicable_tax_rates_wildcard_applies_to_any_unmatched_country— wildcard applies to any unmatched country (BR, JP, AU, CA)test_get_applicable_tax_rates_empty_when_no_match_and_no_wildcard— empty result when no match and no wildcardAcceptance criteria
Reference