PDA

View Full Version : Instructions for change listing price in European currency format (decimal = comma)



Steffen Buschkemper
April 17, 2013, 10:36 PM
Hi @ all who need this feature,

Flynax currently only supports the american and english currency format for listings (decimal = dot).
The topic is not new and has been discussed by me in the forum before.
Because of time constraints the topic has not yet been solved.
That's why I published the solution today for some europeans.

__________________________________________________ __________________________________________________ __________________

Please note that existing listing prices in database with point as decimal instead of comma must be manually changed with follow SQL query!

Login into the Admin Panel and go to Common -> Database
Paste the follow SQL query



UPDATE `{sql_prefix}listings`
SET `price` = replace(`price`, ".",",");


and press the button "Go". Now the decimals of listing prices will be changed with a comma as decimal in database.
__________________________________________________ __________________________________________________ ___________________

NOTICE: Please back up all files before modify!

OK let us start now.

Part 1. Opens the 2 files rlSmarty.class.php and rlValid.class.php (includes -> classes -> ...)

Searches for the function str2money



function str2money( $aParams )
{
$string = is_array($aParams) ? $aParams['string'] : $aParams ;

$len = strlen($string);
$string = strrev($string);

if ( strpos($string, '.') )
{
$rest = substr($string, 0, strpos($string, '.'));
$string = substr($string, strpos($string, '.')+1, $len);
$len -= strlen($rest)+1;
$rest = strrev(substr(strrev($rest), 0, 2)) . ".";
}
elseif ( $GLOBALS['config']['show_cents'] )
{
$rest = '00.';
}

for ( $i = 0; $i <= $len; $i++ )
{
$val .= $string[$i];
if ( (( $i + 1 ) % 3 == 0) && ( $i + 1 < $len ) )
{
$val .= $GLOBALS['config']['price_delimiter'];
}
}

$val = strrev($rest.$val);

return $val;
}


Change the code as follows in both files



function str2money( $aParams )
{
$string = is_array($aParams) ? $aParams['string'] : $aParams ;

$len = strlen($string);
$string = strrev($string);

if ( strpos($string, ',') )
{
$rest = substr($string, 0, strpos($string, ','));
$string = substr($string, strpos($string, ',')+1, $len);
$len -= strlen($rest)+1;
$rest = strrev(substr(strrev($rest), 0, 2)) . ",";
}
elseif ( $GLOBALS['config']['show_cents'] )
{
$rest = '00,';
}

for ( $i = 0; $i <= $len; $i++ )
{
$val .= $string[$i];
if ( (( $i + 1 ) % 3 == 0) && ( $i + 1 < $len ) )
{
$val .= $GLOBALS['config']['price_delimiter'];
}
}

$val = strrev($rest.$val);

return $val;
}


Save and Close!


Part 2. Open the file includes -> classes -> rlListings.class.php

Next find the following code @ line ~ 301 and @ line ~ 606



$data[$fk]['value'] = str_replace(array(',', "'"), '', $data[$fk]['value']);


and change the codes as follow



$data[$fk]['value'] = str_replace(array('.', "'"), '', $data[$fk]['value']);


Save and Close!


Part 3. Open the file includes -> classes -> admin -> rlListings.class.php

Next find the following code @ line ~ 266 and @ line ~ 585



$data[$fk]['value'] = str_replace(array(',', "'"), '', $data[$fk]['value']);


and change the codes as follow



$data[$fk]['value'] = str_replace(array('.', "'"), '', $data[$fk]['value']);


Save and Close!


Part 4. Open templates->"your template"->tpl->controllers-> add_listing.tpl

Find the following script nearly at the end of the file



{literal}
$(document).ready(function(){
$("input.numeric").numeric();
});
{/literal}


and change the code as follow



{literal}
$(document).ready(function(){
$("input.numeric").numeric();
$('input[name="f[price][value]"]').numeric({ decimal : "," });
});
{/literal}


Save and Close!


Part 5. Open templates->"your template"->tpl->controllers-> edit_listing.tpl

Find the following script nearly at the end of the file



{literal}
$(document).ready(function(){
$("input.numeric").numeric();

flynax.mlTabs();
{/literal}{if $config.address_on_map}flynax.onMapHandler();{/if}{literal}
});
{/literal}


and change the code as follow



{literal}
$(document).ready(function(){
$("input.numeric").numeric();
$('input[name="f[price][value]"]').numeric({ decimal : "," });

flynax.mlTabs();
{/literal}{if $config.address_on_map}flynax.onMapHandler();{/if}{literal}
});
{/literal}


Save and Close!


Part 6. Open admin->tpl-> footer.tpl

Find the code @ line ~ 23



$("input.numeric").numeric();


and below (after the above code) add the following code in a new line.



$('input[name="f[price][value]"]').numeric({ decimal : "," });


Save and Close!

Part 7. Download and extract the numeric.zip.
Download: 476

Replace the new numeric.js with existing - via ftp @ folder libs -> jquery -> numeric.js

Ok thats all

Now the Currency Format is for examble 12,34 or 12,00 and
your customers can input prices with comma as decimal. :p


Best regards
Steffen

Steffen Buschkemper
April 18, 2013, 01:25 PM
The only thing that has not been changed is the prices for the plans.
I work on it and will soon publish it here.

Best regards
Steffen

Giuseppe Mollo
April 19, 2016, 07:41 AM
Hello! Thanks for this tutorial! Everything works great!

Mustafa ilker Yonel
November 10, 2017, 09:38 AM
Guten Morgen Steffen,

have you changed the price plans yet ? :laugh:

w