Allow shipping tax rate to be determined by a callable#2423
Merged
alecritson merged 8 commits intolunarphp:1.xfrom Mar 30, 2026
Merged
Allow shipping tax rate to be determined by a callable#2423alecritson merged 8 commits intolunarphp:1.xfrom
alecritson merged 8 commits intolunarphp:1.xfrom
Conversation
Collaborator
|
Thanks @ryanmitchell I think we should avoid closures in config file as this will stop serialization, also maybe instead (or on top) of having to provide a handle Finally I think if we can simply or tidy up the nested if statements that would be ideal. |
Contributor
Author
|
@alecritson nested ifs are removed. It already supports invokeable classes (eg 'shipping_rate_tax_calculation' => MyInvokableClass::class). |
alecritson
approved these changes
Mar 30, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds support for a callable config value for
shipping_rate_tax_calculation, allowing applications to provide custom logic to determine which tax class should be applied to shipping rates.Previously the config only accepted
'default'(system default tax class) or'highest'(highest tax rate among cart lines). Any value other than'default'would fall through to the highest-rate resolver, with no way to supply arbitrary logic.Changes
ShippingRate::getShippingOption()— whenshipping_rate_tax_calculationis set to a callable (closure or invokable class), it is called with theCartinstance and the return value is used as the resolvedTaxClassUsage
An invokable class is also supported: