Try our conversational search powered by Generative AI!

GetTotals() in IOrderGroup - Version 9.4

Vote:
 

Hi

I need to override the method GetTotal in the new IOrderGroup, to my own calculation.

Is there a way?

Thanks

#142548
Dec 14, 2015 15:51
Vote:
 

Hi,

One possible way is to create your class (CustomPurchaseOrder for example) inherits from PurchaseOrder and override it there.

Make sure to use the new class when you use IOrderRepository

/Q

#142549
Dec 14, 2015 16:07
Vote:
 

ok

Why PurchaseOrder?Does PurchaseOrder have it? GetTotals()?

I need to use it like:

((IOrderGroup)Cart).GetTotals() and it will return a class "OrderGroupTotals" with all values.

The problem I have is that TaxTotal is "0"

Juan

#142550
Dec 14, 2015 16:17
Vote:
 

GetTotals is a method of IOrderGroup, so you can override it with your custom PurchaseOrder.

But if your problem is TaxTotal then the solution can be different - implement your own ITaxCalculator and register it as the default implementation in your initialization module.

Regards,

#142551
Dec 14, 2015 16:24
Vote:
 

Is there any sample code of it?

I found "DefaultTaxCalculator"...

#142552
Edited, Dec 14, 2015 16:27
Vote:
 
<p>http://world.episerver.com/documentation/Class-library/?documentId=commerce/9/277D3EB8</p> <p>Here's an example. You just need to implement two methods.</p> <p>/Q</p>
#142554
Dec 14, 2015 16:29
Vote:
 

Perfekt

Thanks Quan!

#142555
Dec 14, 2015 16:31
Vote:
 
<p>Just one more question Quan.</p> <p></p> <p>I did my new class that override the taxcalculation, now how do I register it in my initialization module?</p>
#142557
Dec 14, 2015 16:45
Vote:
 

Some thing like this, your initialization module needs to implement IConfigurableModule

public void ConfigureContainer(ServiceConfigurationContext context)
{
    context.Container.Configure(ce => ce.For<ITaxCalculator>().Add<YourTaxCalculator>());
}

#142558
Dec 14, 2015 16:49
Vote:
 

Thanks!

#142559
Dec 14, 2015 17:01
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.