• Resolved USREC

    (@hawaiirealestate)


    Why won’t this code work?
    <?php
    $x=es_the_property_field( ‘price’, ‘<p>Price: ‘ );
    $y=$x *= .015;
    echo $y;
    ?>

Viewing 5 replies - 1 through 5 (of 5 total)
  • If you want to do math operations, then you should get the price only

    es_get_the_property_field('price')

    Thread Starter USREC

    (@hawaiirealestate)

    Trying

    <?php
    $x = es_get_the_property_field('price');
    echo $x;
    $x=intval($x);
    
    if (is_numeric($x) ) {
    echo "X is a number: ";
    echo $x;
    echo number_format("$x",2)."<br>";
    } else {
    echo "X is not a number.";
    }
    ?>

    But wont show Price, only X is a number: 00.00

    • This reply was modified 2 years, 8 months ago by USREC.
    Thread Starter USREC

    (@hawaiirealestate)

    Anyone use PHP or Javascript?

    Probably it depends on the place you want to fetch the price
    I’ve created my customization by copying template
    \wp-content\plugins\estatik\templates\content-single.php
    to
    \wp-content\themes\my-theme\estatik\content-single.php

    es_get_the_property_field('price') gives me an integer (if I set the price of property with decimal separator, then it gives float / double).

    Seems that your code is placed out of scope – you get NULL there, then converted to integer gives you 0. So checking (after changing the type) if the variable is numeric or not makes no sense.

    • This reply was modified 2 years, 8 months ago by Rafa?.
    Thread Starter USREC

    (@hawaiirealestate)

    Keep getting

    Fatal error: Uncaught Error: Undefined constant “‘price’”

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘PHP Code’ is closed to new replies.