How to convert colon in price field to decimal point seperator

ClassiBase classifieds script Forums Tips and tricks How to convert colon in price field to decimal point seperator

Tagged: , ,

This topic contains 8 replies, has 1 voice, and was last updated by  ClassiBase 2 years, 10 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1432 Reply

    ClassiBase
    Keymaster

    Hi,

    How do I correct the full stops that appear before the price on the ad?

    Example: When I post an ad and enter the price like this £40.00 everything
    is displayed fine however when I enter the price like this £40:00 it
    displays like this £4,000.00

    #1433 Reply

    ClassiBase
    Keymaster

    Hi,

    When price field stored in database it removes all non numeric characters and leaves only “.” as separator cor decimal point. if you define other decimal point separator in “Settings” -> “Currency” for example “,” then it converts that separator to “.” and stores value as float number.

    In your case it removes “:” from 40:00, and number becomes 4000 not 40.00
    if you want to modify and make 40:00 convert to 40.00 then make changes as described below:

    Edit file /sys/app/models/AdField.php line 927

    change
    $val = str_replace(array($currency_decimal_point, $currency_thousands_seperator), array('.', ''), $val);

    to

    $val = str_replace(array(":",$currency_decimal_point, $currency_thousands_seperator), array('.','.', ''), $val);

    which will replace “:” with “.” then convert to float.

    Also make note of this change in case if you update script in future changes you made to script files will be lost.

    Regards.

    #1435 Reply

    Al

    Does that mean a user can input . , or : without changing the value? This is how I want it to work.

    #1439 Reply

    ClassiBase
    Keymaster

    If you want to use .,: as decimal point then change that line to

    $val = str_replace(array(":",",",$currency_decimal_point, $currency_thousands_seperator), array('.','.','.', ''), $val);

    #1438 Reply

    Al

    How do I correct the full stops that appear before the price on the ad?

    #1441 Reply

    ClassiBase
    Keymaster

    Can you explain with example what you mean by “correct” ?

    #1442 Reply

    Al

    I want the user to decide what they want to use , ‘ : ; / but I dont want the script to play about with the value.

    #1443 Reply

    Al

    What if I want to allow the user to input what they want i.e. : , . ; without the script changing the value, how do i do that?

    #1446 Reply

    ClassiBase
    Keymaster

    You can add as many characters you want to be considered as “.” same way as explained above. Just make sure that each array has equal number of items in it.

Viewing 9 posts - 1 through 9 (of 9 total)
Reply To: How to convert colon in price field to decimal point seperator
Your information: