Using additional textfield for old price and compare with new price
I have added an additional textfield for adding the old price of a product, e.g. oldPriceDKK and still have the existing productPriceDKK, which set the product price.
Now I want to return a decimal, so I can compare the two prices and if the old price is greather than product price and a difference on more than 0, I want to do some stuff.
Here both price and basePrice is displayed in same way as long I write the old price with comma as decimal separator. Where teh default price also handle dot as decimal seperator.
The standard price seems to use the product id the get the price from the property which is set in the currency node in Tea Commerce section. But how can handle it in same way with additional price?
Can I get a decimal from the standard price or can I compare the prices in the Price objects?
That's also what I did :) I was wondering how the standard productPriceDKK handle noth comma and dot as decimal separator.
E.g. Price DKK: 2316,00 --> output: 2.895,00 kr. Base price DKK: 2392,00 --> output: 2.990,00 kr.
But with dot as decimal separator: Price DKK: 2316.00 --> output: 2.895,00 kr. Base price DKK: 2392.00 --> output: 299.000,00 kr.
also from the Price object can I get the values to compare the prices?
The price output is written like this: @price so I guess that a price object both incl. price and currency - is there a method or property the extract the price value?
The price object has a lot of properties. Like price.Value which is the raw price. price.Vat is the Vat. price.WithVat is price including VAT.
Tea Commerce tries to handle both comman and dot. But it depends on what language/culture your website is running. Because . is normal a seperator for a thousand in american culture.
Using additional textfield for old price and compare with new price
I have added an additional textfield for adding the old price of a product, e.g. oldPriceDKK and still have the existing productPriceDKK, which set the product price.
Now I want to return a decimal, so I can compare the two prices and if the old price is greather than product price and a difference on more than 0, I want to do some stuff.
What I have done so far is:
Here both price and basePrice is displayed in same way as long I write the old price with comma as decimal separator. Where teh default price also handle dot as decimal seperator.
The standard price seems to use the product id the get the price from the property which is set in the currency node in Tea Commerce section. But how can handle it in same way with additional price?
Can I get a decimal from the standard price or can I compare the prices in the Price objects?
/Bjarne
Just get the old price using TC.GetPropertyValue and then use Tc.FormatPrice
Hej Anders
That's also what I did :)
I was wondering how the standard productPriceDKK handle noth comma and dot as decimal separator.
E.g.
Price DKK: 2316,00 --> output: 2.895,00 kr.
Base price DKK: 2392,00 --> output: 2.990,00 kr.
But with dot as decimal separator:
Price DKK: 2316.00 --> output: 2.895,00 kr.
Base price DKK: 2392.00 --> output: 299.000,00 kr.
also from the Price object can I get the values to compare the prices?
The price output is written like this: @price so I guess that a price object both incl. price and currency - is there a method or property the extract the price value?
The price object has a lot of properties. Like price.Value which is the raw price. price.Vat is the Vat. price.WithVat is price including VAT.
Tea Commerce tries to handle both comman and dot. But it depends on what language/culture your website is running. Because . is normal a seperator for a thousand in american culture.
Okay, the documentation just says that it returns an price object, but not which method and properties it has.. :)
But of course I could add the references to a Visual Studio project and explore, which method and properties it has..
Yes, I have seen some examples before including the CultureInfo object to get the right decimal value related to the language/culture something like this: http://msdn.microsoft.com/en-us/library/ew0seb73(v=vs.110).aspx ..
is working on a reply...