Your address will show here +12 34 56 78

Home Forums WP ESTATE – Real Estate WordPress Theme FORUM Format price remove commas and add blank

This topic contains 15 replies, has 10 voices, and was last updated by  atozreal 2 years, 2 months ago.

  • Author
    Posts
  • #6581

    Anna
    Keymaster

    If you have some PHP knowledge, you’ll find these instructions useful.

    You have to look for $price = number_format($price); in the entire theme and change the price format to French format (this is the link to the PHP documentation for price format) http://php.net/manual/en/function.number-format.php

    Example:
    in single-estate_property.php file
    line 166 you’ll find
    $price = number_format($price);

    Modify to
    $price = number_format($price, 2, ',', ' ');

    pin management

     

     

    price format

    ———–

    Change price format in COMPARE form:

    In compare_listings.php you have 2 lines to change (around line 66)

    `if ($where_currency == ‘before’) {

    $price = $currency . ‘ ‘ . number_format(intval( get_post_meta($post->ID, ‘property_price’, true) ) );

    } else {

    $price = number_format( intval( get_post_meta($post->ID, ‘property_price’, true) ) ). ‘ ‘ . $currency;

    }
    `
    Look here how number format is functioning : http://php.net/manual/en/function.number-format.ph

    for ex

    $price = $currency . ' ' . number_format(intval( get_post_meta($post->ID, 'property_price', true) ) ,2,".",",");

    • This topic was modified 3 years, 6 months ago by  Anna.
    • This topic was modified 3 years, 5 months ago by  Anna.
    • This topic was modified 3 years, 5 months ago by  Anna.
    • This topic was modified 3 years, 5 months ago by  Anna.
    • This topic was modified 3 years, 5 months ago by  Anna.
    • This topic was modified 3 years, 5 months ago by  Anna.
    • This topic was modified 3 years, 5 months ago by  Anna.
    • This topic was modified 3 years, 3 months ago by  Anna.
    • This topic was modified 2 years, 11 months ago by  Anna.
  • #8083

    Anna

    Sort by price after modifying number format

    Replace this line in property-list.php :
    ‘orderby’ => ‘meta_value’,
    by
    ‘orderby’ => ‘meta_value_num’,

    It works with french number format : $price = number_format($price, 0, ‘,’, ‘ ‘);

    • This reply was modified 3 years, 5 months ago by  Anna.
  • #30704

    Anna
    Keymaster

    If you want to add decimals:

    First look for all number_format occurrences.

    Some times you will find
    $price = number_format( intval( get_post_meta($post->ID, ‘property_price’, true) ) ). ‘ ‘ . $currency;

    Replace intval with floatval and should be ok

    • This reply was modified 3 years, 5 months ago by  Anna.
  • #48041

    Michele D.

    Hi Anna… and about the box that is located in the map at the top?

    this: http://dalexdesign.net/works/img-wp-currency.jpg

  • #48274

    crerem

    Hello,
    You need to edit libs/pin-management.php file. the price is set around line 140.
    Thanks

    • #103818

      aromboli
      Participant

      It didn’t work for me the change in the pinmanagement file. It worked for all other files. What could the problem be?

      • This reply was modified 2 years, 7 months ago by  aromboli.
  • #100008

    alessiocandelma
    Participant

    If I want change the prices appears in the title with a range of prices for instance: from € 100 to € 500, is it possible?

    Thanks

    Alessio

  • #100210

    aesse83
    Participant

    Hi all, about price format id like to change separator from ‘,’ to ‘.’, i mean for example : € 400,000 then id like to have it as 400.000,00 is it possible to modify it on wp residence? and if yes which files have i to mod? thx 🙂

  • #100387

    Anna
    Keymaster

    Hi Alessio

    Regarding

    If I want change the prices appears in the title with a range of prices for instance: from € 100 to € 500, is it possible?

    –> Search by price would not work then. You would have to convert field NUMBER to FIELD text – see this forum as it’s a lot to change – http://wpestate.org/forums/topic/change-price-field-to-text/

    Thank you
    anna

  • #100388

    Anna
    Keymaster

    Hi aesse83

    In WP RESIDENCE you have to follow the same steps.

    I did a theme search to see where the code is in WP RESIDENCE. Follow the same steps and instructions as explained above.

     

    number format residence

    Thank you
    Anna

  • #100401

    aesse83
    Participant

    yeah, right i’ve already fixed that and it worked out, thanks anyway anna!

  • #100418

    nguyentrunghoa
    Participant

    Hi Anna,

    Would you mind if share for me what software you use to find the same code ( $price = number_format($price);) on all files of the theme as the picture you show?
    http://wpestate.org/wp-content/uploads/2014/10/number-format-residence.png

    Thanks so much!

    • #101277

      altuner
      Participant

      Hi nguyentrunghoa,

      The used software name is: Dreamweaver ( i use version CS6)

      1.- Open the software
      2.- Press Ctrl + F (to find)
      3.- Select by Find in Folder… (and save the map where you save the theme sample: C:\Theme 1.71\wpresidence\

      If you want the price format in : €500.000 (dot replace the current comma by thousand) follow the steps:

      Copy and Past it to Find
      $price= number_format($price);

      Copy and Past it to Replace
      $price = number_format($price, 0, ‘,’, ‘.’);

      Select now Replace All

      Repeat this with:
      $price=number_format($price);

      (some files write without space between = and number)

  • #102229

    mmatos
    Participant

    Hi!

    I have implemente this, but now when I put a price of 1200.67 It comes out with 1.200,00

    if ($price != 0) {
                   $price = number_format($price, 2, ',', '.');
                   if ($where_currency == 'before') {
                       $price = $currency . ' ' . $price;
                   } else {
                       $price = $price . ' ' . $currency;
                   }           
               }else{
                   $price='';
               }
    

    Any suggestions how to change this?

  • #102803

    coutogomes
    Participant

    Hi Anna,

    deveriam ser realizadas

    I understand that modifications should be realized in childtheme, because if you release a new version of the theme we lose this modifications.

    Otherwise, if we copy all files to childtheme, and you release a new version of this files, we lose yours modifications.

    Not have any other way to change de thousand separator? Like function.php or new release via theme options?

    tks.

  • #118928

    atozreal
    Participant

    yup, i already do this thing

You must be logged in to reply to this topic.