Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > custom macro : retrieve the total price without tax of an order in the invoice template View modes: 
User avatar
Member
Member
Fabien Calais - 11/23/2010 3:34:11 AM
   
custom macro : retrieve the total price without tax of an order in the invoice template
Hi,

I have to display the total price without tax of an order in the invoice template.
So, i want to write a custom macro to do this.
Any idea to achieve this?

the CustomOrderInfoProvider object give me access only to the GetTotalPrice function who is the TTC price.

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 11/25/2010 4:00:43 AM
   
RE:custom macro : retrieve the total price without tax of an order in the invoice template
Hi,

could you please specify if you meant invoice in the shopping card preview or in the invoice template used in the Tools - Ecommerce - order - Invoice tab?

1. Shopping card preview - you can insert following code into file: ~/CMSModules/Ecommerce/Controls/ShoppingCart/ShoppingCartPreview.ascx.cs

double price = ShoppingCartInfoObj.TotalPrice;
double tax = ShoppingCartInfoObj.TotalTax;
double priceWithoutTax = price - tax;

2. Tools - Ecommerce - order - Invoice tab - you can use following custom macro code:


switch (expression.ToLower())
{
case "custom":
match = true;

// Get shopping cart object from resolver

CMS.Ecommerce.ShoppingCartInfo cartObj = sender.SourceObject as CMS.Ecommerce.ShoppingCartInfo;
double tax = Convert.ToDouble(cartObj.TotalTax);
double price = Convert.ToDouble(cartObj.TotalPrice);

result = (price - tax).ToString();
break;
}


Best regards,
Ivana Tomanickova

User avatar
Member
Member
Fabien Calais - 11/25/2010 6:43:19 AM
   
RE:custom macro : retrieve the total price without tax of an order in the invoice template
Thanks a lot !
It's exactly what i am looking for.

In fact, I forgot the invoice in the shopping card preview.

Just one more question :
If i want to calculate the total price without tax and excluding the shipping cost,
how can i do?

do i have to use cartObj.TotalItemsPrice in place of cartObj.TotalPrice
or retrieve the Shipping cost (price - tax - shipping) by using cartObj.TotalShipping?

Which is the best?

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 11/25/2010 7:20:01 AM
   
RE:custom macro : retrieve the total price without tax of an order in the invoice template
Hi,

these two methods are equivalent. You can use both of them.

Best regards,
Ivana Tomanickova

User avatar
Member
Member
Fabien Calais - 11/25/2010 8:29:00 AM
   
RE:custom macro : retrieve the total price without tax of an order in the invoice template
thanks for your prompt answer !