Developer forum

Forum » Development » Prices with different roundings

Prices with different roundings

Anders Ebdrup
Anders Ebdrup
Reply

Hi Dynamicweb,

 

I need to display my unit prices with 5 decimals but all other prices should be displayed with 2 decimals. I have tried this in my cartline templateextender:

                var rounding = new Rounding();
                rounding.Decimals = 5;
                var currencyWithFullDecimals = new Currency(base.OrderLine.Price.Currency.Code);
                currencyWithFullDecimals.RoundingId = "tmp";
                currencyWithFullDecimals.Rounding = rounding;
                msrpUnitPriceWithoutVATPriceInfo.Currency = currencyWithFullDecimals;

                Ecommerce.Frontend.Renderer.RenderPriceInfo(msrpUnitPriceWithoutVATPriceInfo, template,
                    "Smartpage:SpMsrpUnitPrice");

 

But it seems like I cannot runtime overrule a rounding on a currency, as this is cached. Do anyone have an idea of a workaround to overrule roundings for specific prices while still using the default setup?

 

Best regards, Anders


Replies

 
Anders Ebdrup
Anders Ebdrup
Reply

Hello again,

 

Could this part (see screenshot) from Currency.vb be moved a bit further down: https://www.screencast.com/t/HKRBhpyO as it then would be possible to override the roundings from the api?

 

Best regards, Anders

 
Nicolai Pedersen
Reply

Hm - simple question!

Do you might have the unrounded price available in the template extender? And might be able to create a new tag instead with the 5 decimals?

Moving the code looks like a risky thing - then I woudl rather give you something to hook into instead. Lets discuss Thursday in the bar....!

BR Nicolai

 
Anders Ebdrup
Anders Ebdrup
Reply

Sounds like a great idea with the bar - but I still need to find a reasonable solution :-)

 

It does not work with just displaying the price directly as I need to have the currency formating and we have a lot of currencies on the site.

 
Nicolai Pedersen
Reply

No problem - will bring my laptop to the bar... Extensibility hook I think is the best option.

 
Nicolai Pedersen
Reply

TFS#39915

 
Anders Ebdrup
Anders Ebdrup
Reply

Hi Nicolai,

 

How far is this change from reaching the 9.3-branch?

 

Best regards, Anders

 
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Anders

It is in Dynamicweb.Ecommerce.dll 1.3.5+

Attached the changeset in case you do not remember!

BR Nicolai

Capture.PNG
Votes for this answer: 1
 
Anders Ebdrup
Anders Ebdrup
Reply

Nice, thanks, and it is actually working! Amazing what kind of work can be done in the bar! :-)

 
Nicolai Pedersen
Reply

Glad to hear. More drinking is the learning wink

 

You must be logged in to post in the forum