Developer forum

Forum » Development » Product field, is getting rounded

Product field, is getting rounded

Dmitrij Jazel
Reply

Hi Guys,

Just wanted to know if someone ever has simmilar issue.

We disabled rounding on the shop, and I have some products with some custom fields, that are of type "Decimal".

One of the field values is "2.745" as a result when I am reading it in the razor, I am getting "2.75" out of

@i.GetString("Ecom:Product:Field.variable.Value")

No rounding hapens in front-end I am trying to read "Raw" value.

Is there any way I can assure that this field gets no auto-rounding?

 

Regards,

Dmitrij


Replies

 
Nicolai Høeg Pedersen
Reply

Use i.GetDouble...

 
Dmitrij Jazel
Reply

Hi Nicolai, 

 

Thanks for suggestion, was hoping it would help.

Just tried: i.GetDouble("Ecom:Product:Field.variable.Value");

Still getting the same :-/ any other suggestions why this can happen? First of all why would it ever round this value, no matter if you are calling for string, or double, it is still the constant value - and if no rounding setting applied to it why would it round?

Application: 8.4.1.2

 

/Dmitrij

 

 

 
Nicolai Høeg Pedersen
Reply

Hi Dmitrij

Just looked into the code. All custom fields that are doubles, are rounded using the currency formatter - that will not do any rounding if disabled, but always return only 2 decimals, resulting in a rounding on the third decimal...

Then you have the .Clean version of the tag, that for some reason is also rounded and therefore not usable either...

So, to fix this mess, I've added a Ecom:Product:Field.variable.Value.Raw template tag that is an unformatted double value, rendered as a double so you can get it with GetDouble. TFS#15647 - to be released with next 8.4.1 hotfix.

Nicolai

 
Dmitrij Jazel
Reply

Sounds great Nicolai!

This "Ecom:Product:Field.variable.Value.Raw template tag" would actually be a really good thing (in my oppinion), Just to get exact value that is saved in the field, without any formating or anything.

I am aactually about ot update this solution, was thinking of updating this particular solution to 8.5.X

Hope that I will be able to find this template tag in future versions of DW to come, can I? Just making sure :-)

And lastly would appreciate even more if you could share the hotfix link when ready (if possible). :-)

 

/Dmitrij

 
Nicolai Høeg Pedersen
Reply

Hi Dmitrij

All bugs are in the release list when they are published.

And if it is released for 8.4.1.* it will be in all releases after that.... That will include 8.5

Nicolai

 
Dmitrij Jazel
Reply

Hello Nicolai,

 

Just made a test on a newest 8.5.0.0, and still am getting the same rounding issue,

You meant that we should wait to 8.5.0.1 or there will be a hotfix link available of some sort?

Sorry if I am missing something very basic here, but I need to get this one fixed one way ot another.

 

Regards,

Dmitrij

 

 
Nicolai Høeg Pedersen
Reply

Hi Dmirij

Yes, you need to wait for the 8.5.0.1 - since I cannot put code into a release that has been out there for weeks.

So when I write 8.4.1* and further, all branches with versions higher than that AND that has a hotfix release efter the date, will have the correction.

 
Dmitrij Jazel
Reply

That is exactly what puzzled me, thanks for clarifying that one for me ;-)

Ok Good :-) as long as it is included in 8.5.0.x versions to come, that is more than OK with me :-)

 

Regards,

Dmitrij

 
Kristian Kirkholt
Reply

Hi Dmitrij

The problem with "Custom product fields of type double are rendered rounded to 2 decimals and as a string"
Bug #15647  has now been fixed in version 8.4.1.16

You are able to find this build in the download section:

http://developer.dynamicweb-cms.com/downloads/dynamicweb-8.aspx

Please contact Dynamicweb Support if you need any additional help regarding this.

Kind Regards

Dynamicweb Support
Kristian Kirkholt

 

You must be logged in to post in the forum