Developer forum

Forum » CMS - Standard features » Prices with more than 2 decimals

Prices with more than 2 decimals

Caro De Weze
Reply

Hi,

Some of our products have prices with more than 2 decimals. How can I show this?

Previously, you had to ensure that 'Round price calculations by currency culture' was disabled in the ecommerce settings, but I can no longer find this setting. 

I currently have nothing active in 'Calculation rounding', but the prices are still only up to 2 decimals:

Kind regards,
Caro De Weze


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Caro

In Dynamicweb 10 the number of decimals is controlled by the numberformat info (which is controlled by .NET) from the culure set on the currency and is using its currency settings. This means that if you e.g. use tunisian culture, which contains 3 decimals.

Can you ellaborate what the use case is in this regard? Is it because you have prices in general with 3 decimals, or products where the price is so low that 3 decimals makes sense (e.g. below 1 EUR). And what about the cart - e.g. should orderline totals etc. also be 3 digits?

As I see it, more than 2 decimals makes little sense in most cases - so I would like to understand the full context of your question.

BR Nicolai

 
Caro De Weze
Reply

Hi Nicolai,

In this case there are prices with a maximum of 5 decimals and these must be shown. The reason for this is that often a huge number of items are purchased and then those decimals make a big difference. They must only be shown with so many decimals for a product, but of course the total price must take into account the multiple decimals even if only two are shown there.

Kind regards,
Caro De Weze

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Caro

You can do something like this in your template - in Swift this would be the Files\Templates\Designs\Swift-v2\Components\Price.cshtml template:

if (Model.Price.Price > 0.9)
{
    price = Model.Price.PriceFormatted;
}
else
{
    price = Model.Price.Price.ToString("C5", Dynamicweb.Ecommerce.Common.Context.Currency.GetCultureInfo());
}

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Dynamicweb calculates with all the decimals - so it is a matter of rendering what is needed.

 
Caro De Weze
Reply

Hi Nicolai,

That indeed works if I add it to Files\Templates\Designs\Swift\Paragraph\Swift_ProductPrice.cshtml. Thank you!

Kind regards,
Caro De Weze

 

You must be logged in to post in the forum