Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

How do I configure Money objects?

Go to End

4 Posts   2295 Views


Community Member, 279 Posts

28 October 2010 at 3:08am

Edited: 28/10/2010 3:11am

I noticed that a class Money exists, which has much more to offer than the class Currency. But how do I configure an object of the class Money? For example where do I call the method setAllowedCurrencies()? I would have expected some static methods which could be called in the _config.php.


Forum Moderator, 5523 Posts

28 October 2010 at 12:20pm

You use the setAllowedCurrencies() function It's not a static but instance level function now so you can configure it on a per field type or define your own statics for it.


Community Member, 279 Posts

11 November 2010 at 9:42pm

Edited: 11/11/2010 9:52pm

Thanks for your help willr.
I found a bug concerning the money class. I have a class "Order" which has a relation and an attribute with similar name:

public static $db = array(
        'AmountTotal' => 'Money',
        'ShippingFee' => 'Money'
    public static $has_one = array(
        'shippingFee' => 'ShippingFee'

If I call $ShippingFee.Nice in a template I never get results. I presume it has something to do with UpperCamelCase/lowerCamelCase. As I renamed the property to 'ShippingFeeTotal' it worked.


Community Member, 279 Posts

18 November 2010 at 12:59am

Money-Objects that have no Currency set will never end up in the frontend. I learned this the hard way ;) The amount is set with setAmount($someFloat) the objects needs a currency set to. If it is euro like in my case: setCurrency('EUR'). I had setCurrency('eur') before and it did not return any currency to the frontend when i called my Money object like $Price.Nice. Furthermore I had to tweek a core class to get our euro character displayed:

<currency type="EUR">
		<displayName count="other">Euro</displayName>