November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
My initialization module is declared as:
[InitializableModule]
[ModuleDependency(typeof(EPiServer.Commerce.Initialization.InitializationModule))]
public class InitializationModule : IConfigurableModule
{
and I use the ConfigureContainer like :
public void ConfigureContainer(ServiceConfigurationContext context)
{
context.StructureMap().Configure(c =>
{
c.For<ITaxCalculator>().Use<MyTaxCalculator>();
In a block controller, if I add ITaxCalculator to a constructor, I get my object(MyTaxCalculator).
In our code, we still call CartHelper.RunWorkflow(OrderGroupWorkflowManager.CartPrepareWorkflowName);
I know cart helper has been replaced and will soon be obsolete, but we can't do the change now.
Is it because I don't use yet the IOrderRepository that the calculators don't works?
Hmm, it might be a bug here. I'm not sure - I have to check and will get back to you.
I asked a developer who has more experience in this area than me (he actually worked in this change in Commerce 12), still waiting for his response)
Hi Yan,
In calculators, we are cache the tax value of order group, shipment and line item. So, if it cached, it will not call to the tax calculator anymore.
Please check the value of flag like:
IOrderGroupCalculatedAmount.IsTaxTotalUpToDate
IShipmentCalculatedAmount.IsShippingTaxUpToDate or
ILineItemCalculatedAmount.IsSalesTaxUpToDate
/Tuan
Where can I check these flags? Like I said earlier, we still use carthelper and we call the default workflows (like CartPrepare, CartValidate and CartCheckout).
I did another test, this time by using the OrderGroupCalculator.
I've added breakpoints in each functions and they never get called:
public class TestCalculator : DefaultOrderGroupCalculator
{
public TestCalculator(IOrderFormCalculator orderFormCalculator)
: base(orderFormCalculator)
{ }
protected override Money CalculateTotal(IOrderGroup orderGroup)
{
var test = orderGroup.Name;
return base.CalculateTotal(orderGroup);
}
protected override void ValidateTotal(Money money)
{
var test = money.Amount;
base.ValidateTotal(money);
}
protected override Money CalculateSubTotal(IOrderGroup orderGroup)
{
var test = orderGroup.Name;
return base.CalculateSubTotal(orderGroup);
}
protected override void ValidateSubTotal(Money money)
{
var test = money.Amount;
base.ValidateSubTotal(money);
}
protected override Money CalculateHandlingTotal(IOrderGroup orderGroup)
{
var test = orderGroup.Name;
return base.CalculateHandlingTotal(orderGroup);
}
protected override void ValidateHandlingTotal(Money money)
{
var test = money.Amount;
base.ValidateHandlingTotal(money);
}
protected override Money CalculateShippingSubTotal(IOrderGroup orderGroup)
{
var test = orderGroup.Name;
return base.CalculateShippingSubTotal(orderGroup);
}
protected override void ValidateShippingSubTotal(Money money)
{
var test = money.Amount;
ValidateShippingSubTotal(money);
}
protected override void ValidateTaxTotal(Money money)
{
var test = money.Amount;
base.ValidateTaxTotal(money);
}
protected override Money CalculateTaxTotal(IOrderGroup orderGroup)
{
var test = orderGroup.Name;
return base.CalculateTaxTotal(orderGroup);
}
Here's how I registered my class:
[InitializableModule]
[ModuleDependency(typeof(EPiServer.Commerce.Initialization.InitializationModule))]
public class InitializationModule : IConfigurableModule
{
...
public void ConfigureContainer(ServiceConfigurationContext context)
{
context.StructureMap().Configure(c =>
{
c.For<IOrderGroupCalculator>().Singleton().Use<TestCalculator>();
Ok, i've found out why my calculators were never called, it was because of this specific line in ecf.app.config:
<add feature="WorkflowsVNext" state="Disabled" type="Mediachase.Commerce.Core.Features.WorkflowsVNext, Mediachase.Commerce"/>
I just commented this line and it now works
Hi,
I'm upgrading from Commerce 11 to 12 and I saw there's now calculators that we can use to do our custom calculations(ex: taxes and totals).
In version 11, we had activity flows with custom classes from OrderGroupActivityBase to calculate our taxes and Totals.
Do we still need those or can I only use a custom class from DefaultTaxCalculator to calculate my taxes?
I tried removing my custom activity flows (removed the project from the solution and edited my ecf.workflow.config) and registering my custom tax class like this:
context.StructureMap().Configure(c =>().Use();
{
c.For
but it never gets called.