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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

E-Commerce Modules /

Discuss about the various e-commerce modules available:
Ecommerce, SS Shop, SilverCart and SwipeStripe
Alternatively, have a look the shared mailinglist.

Moderators: martimiz, Nicolaas, Sean, Ed, frankmullenger, biapar, Willr, Ingo, Jedateach, swaiba

Money input mask issue


Go to End


4 Posts   1723 Views

Avatar
charlesearch

Community Member, 3 Posts

25 August 2014 at 5:07pm

Greetings,

I am new to both Silverstripe and PHP, having used both now for about 5 months. I am building an e-commerce site using silversrtipe 3.1, and have encountered a problem entering product prices.

Silverstripe "corrects" any dollar entry that has zeros after the decimal point. So, if I enter 5.00 (5 dollars) as a product price, when I save or publish the page, the entry is corrected to just the number 5. The decimal and the two zeros that follow it are removed.

Any idea how to turn this off?

thank you

Avatar
SparkGreen

Community Member, 6 Posts

25 August 2014 at 6:27pm

It sounds like the issue could be with your DB definition. Can you post your $db array from that model?

Avatar
charlesearch

Community Member, 3 Posts

27 August 2014 at 3:30am

Hi again,

Here it is...

private static $db = array(
'ProductNumber' => 'Text',
'Units' => 'Int',
'Price' => 'Currency',
'Caption' => 'Text',
'ProductOptions'=> 'HTMLText',
'ProductPr' => 'HTMLText',
'DiscountPr' => 'HTMLText',
'Related' => 'Text'
);

Avatar
charlesearch

Community Member, 3 Posts

28 August 2014 at 7:52am

Ok. I've got it. I changed the field from "TextField" to "CurrencyField" , and used the Nice function provided by CurrencyField in the template.

Thanks!