simpliko / wpadverts

WordPress Classifieds Plugin
https://wpadverts.com/
GNU General Public License v2.0
20 stars 11 forks source link

CHF (Swiss Francs) need “space” before price #167

Closed swissino closed 1 year ago

swissino commented 1 year ago

Hello, When using WPAdverts with swiss francs currency (CHF), price should be shown like this: CHF 15.00 instead of CHF15.00. we need a space between CHF and 15.00. We changed it manually at every updates but it would be great to have it fixed in next update. this is the code (edited):

include/functions.php (Row 298):

if( $c['sign_type'] == 'p' ) {
    #return $sign.$number;
    return $sign.' '.$number;
} else {
    #return $number.$sign;
    return $number.' '.$sign;
}
gwin commented 1 year ago

Hi, we are planning a bigger update for the currencies so I do not want to make changes there yet, in the meantime, you can put the code below in your theme functions.php file or create a blank plugin and paste it there, it will add the white space between price and currency sign without changing original source code

add_filter( "_adverts_currency_list", function( $l ) {
    $space = array( "CHF" );
    foreach( $l as $k => $a ) {
        if( in_array( $a["code"], $space ) ) {
            $l[$k]["sign"] = " " . $l[$k]["sign"];
        }
    }
    return $l;
} );