I have installed the Sitecore.StoreFront solution by following the official deployment's guide. I have also got from github the latest source code's version which I'm using as base for my commerce project.
I'm trying to calculate cart's VAT. By design the storefront solution uses a GlobalTaxPolicy which is not suitable for what I need to do (in Italy VAT calc is item based) so I changed the tax's policy in my Environment from Sitecore.Commerce.Plugin.Tax.GlobalTaxPolicy
to Sitecore.Commerce.Plugin.Tax.ItemTaxPolicy
.
The problem now is that there is not any documentation on how to use or extend the ItemTaxPolicy, so I though to calculate taxes by using a cartline adjustments, but when I add a new CartAdjustment
to the CommerceCartLine.Adjustments
, it is ignored and my adjustments is lost.
Any idea to solve these problems?
UPDATE 2
After read the Creating your first plugin guide in the SiteCore Commerce Developer's Guide, I made a banal tax plugin just do try how the engine works. Now the problem is that my Run method never runs. This is my banal class's code:
[PipelineDisplayName("VAT.CalculateCartLinesTaxBlock")]
public class VATBlock : CalculateCartLinesTaxBlock
{
public override Task<Cart> Run(Cart arg, CommercePipelineExecutionContext context)
{
Condition.Requires(arg).IsNotNull("The argument can not be null");
return Task.FromResult<Cart>(arg);
}
}
This is the registration block in ConfigureSitecore.cs:
public void ConfigureServices(IServiceCollection services)
{
var assembly = Assembly.GetExecutingAssembly();
services.RegisterAllPipelineBlocks(assembly);
services.RegisterAllCommands(assembly);
services.Sitecore().Pipelines(
config => config
.ConfigurePipeline<ICalculateCartLinesPipeline>(c =>
{
c.Add<VATBlock>().Before<CalculateCartLinesTotalsBlock>();
})
);
}
I tried also to:
- Insert it after the Plugin.Tax.CalculateCartLinesTaxBlock
- Insert it and then remove the Plugin.Tax.CalculateCartLinesTaxBlock
but in the NodeConfiguration file, my plugin is never added in the pipeline (before or after) so my function never run.
What am I doing wrong?