Developer forum

Forum » Development » How to render a price ins a custom tag?

How to render a price ins a custom tag?

Martin Nielsen
Reply

Hi DW,

I'm trying to render tag of type Priceinfo. But i'm having trouble applying VAT.

So far i have this code:

double price = 0;
double.TryParse( productToUse.ProductFieldValues.GetProductFieldValue( "BeforeGrossDKK" ).Value.ToString(), out price );
Dynamicweb.eCommerce.Prices.PriceRaw pr = new Dynamicweb.eCommerce.Prices.PriceRaw( price, Dynamicweb.eCommerce.Common.Context.Currency );
Dynamicweb.eCommerce.Prices.PriceCalculated pi = new Dynamicweb.eCommerce.Prices.PriceCalculated( pr );
Dynamicweb.eCommerce.Frontend.Renderer.RenderPriceInfo( pi, _template, "Co3.Custom.Price" );

But when rendering my tag rendering my tag, no VAT is applied. Is there an easy way to get the current VAT from Context and apply it to my PriceInfo?

My tag is only for viewing and is never used in calculations, but i'd like to have the flexibility to use all the template features that a PriceInfo can have.

 


Replies

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

Hi Martin,

 

If the VAT is the standard VAT and not a custom VAT, then you should use this Constructor overload:

pi = new PriceCalculated(productToUse, pr);

 

Hope this helps :)

 

- Jeppe

 

 

You must be logged in to post in the forum