New Tax Provider Registration¶
In order to calculate taxes in Virto Commerce, register at least one TaxProvider
implementation.
Define new tax provider¶
To define a new tax provider, you need to:
- Create a new module.
-
Create a class derived from the
TaxProvider
abstract class and override theCalculateRate
method: -
Register your module class in the DI container. This must be done in the
PostInitialize
method. You can also associate the settings, which will be used in your method and can be changed in the management UI.public void PostInitialize(IApplicationBuilder applicationBuilder) { ... var settingsRegistrar = applicationBuilder.ApplicationServices.GetRequiredService<ISettingsRegistrar>(); var taxProviderRegistrar = applicationBuilder.ApplicationServices.GetRequiredService<ITaxProviderRegistrar>(); taxProviderRegistrar.RegisterTaxProvider<FixedRateTaxProvider>(); //Associate the settings with the particular tax provider settingsRegistrar.RegisterSettingsForType(Core.ModuleConstants.Settings.FixedTaxProviderSettings.AllSettings, typeof(FixedRateTaxProvider).Name); ... }
All settings may have default values that can be used for default methods if not overridden by custom values later.
Enable and configure tax provider for store¶
After your module is installed in your target system, all tax providers should appear and be available for configuration in every store in your system (Store → Tax providers → widget). You can configure tax provider for each store individually:
- Enable or disable a provider for the current store.
- Edit all settings and what you define for the tax calculation provider
- Use a custom UI for a more detailed tax provider configuration
After you complete the configuration, your tax provider will be used for tax calculation of orders in the store.
UI customization¶
If our standard user interface is not enough, you may consider implementing your own UI for managing tax providers through the standard UI extension point (widget container with the taxProviderDetail
group).