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.

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, frankmullenger, biapar, Willr, Ingo, Jedateach, swaiba, simon_w

Money input mask issue


Reply

4 Posts   200 Views

Avatar
charlesearch

25 August 2014 at 5:07pm Community Member, 3 Posts

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

25 August 2014 at 6:27pm Community Member, 6 Posts

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

Avatar
charlesearch

27 August 2014 at 3:30am Community Member, 3 Posts

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

28 August 2014 at 7:52am Community Member, 3 Posts

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!