Hi

I'm trying to set my price format to text when the value is $0.00

following are the codes created, it works but it show both
text and figure after updating which is wrong and what i would have is
when the price is $0.00 it show call for price

result shown: $0.00
Call For Price

function priceFormat($price, $dispNull = FALSE){

if($price == TRUE){

global $currencyVars;

$price = $price * $currencyVars[0]['value'];

return $currencyVars[0]['symbolLeft'].sprintf("%.".$currencyVars[0]['decimalPlaces']."f", $price).$currencyVars[0]['symbolRight'];

} elseif($dispNull == TRUE) {
global $currencyVars;
return $currencyVars[0]['symbolLeft'].sprintf("%.".$currencyVars[0]['decimalPlaces']."f", 0.00).$currencyVars[0]['symbolRight'];

} else {

return "call for price";

}

}

would appreciate if anyone can help

thanks in advance

    if you are setting $price = 0.0
    it's working perfctly

    I think there might be an issue in other values which is comming so first check all the valuse such as
    $currencyVars[0]['decimalPlaces'], $currencyVars[0]['symbolRight']

    if all is correct then just replace the if condition
    you condition:
    if($price == TRUE)

    just replace it by if($price == TRUE && $price!=0)
    this will do your work or chang the condition as needed
    as whn u r calling $price==TRUE it works either the value is set to 1 or 0
    so you need to specify it correctly

      try replacing if($price == TRUE){ with

      if($price === TRUE){

        an error encounter

        Parse error: syntax error, unexpected '}'

          yes, but getting error

          for the following code

          } elseif($dispNull == TRUE) {
          Parse error: syntax error, unexpected '}'

            you can revert to your code which you posted very first. Then, simply replace == with ===

              still get the same error

              Parse error: syntax error, unexpected '}' for

              global $currencyVars;
              return $currencyVars[0]['symbolLeft'].sprintf("%.".$currencyVars[0]['decimalPlaces'], $currencyVars[0]['symbolRight']

                Thats funny, tha last test would be revert your complete code to original one (with ==) and see the error.

                  still the same error

                  Parse error: syntax error, unexpected '}'
                  } elseif($dispNull == TRUE) {

                  if i remove "}" i get this
                  Parse error: syntax error, unexpected T_ELSEIF

                    You need to fix this error first by matching all the braces, then use the === operator.

                    added: I copied and ran the code you posted, there is no syntax error. Seems you have problem some where else.

                      hi

                      thanks, i got it but now it show call for price twice instead of once and
                      items with price also change to call for price.

                      your help is greatly appreciated

                      thanks in advance

                        I just don't understand the need of if($price === TRUE){ condition. if you want to check that the price is a numric, use

                        if(is_numeric($price)){
                        

                          had tried, it show both when the price is 0.00

                          result: 0.00 and call for price

                            here is the code I'm trying. Logically, it should print only once and it is. I think you are calling multiple time by accident.

                            <?
                            echo priceFormat(0);
                            
                            function priceFormat($price, $dispNull = FALSE){
                            
                            if(is_numeric($price)){
                            
                            global $currencyVars;
                            
                            
                            $price = $price * $currencyVars[0]['value'];
                            
                            return $currencyVars[0]['symbolLeft'].sprintf("&#37;.".$currencyVars[0]['decimalPlaces']."f", $price).$currencyVars[0]['symbolRight'];
                            
                            } elseif($dispNull == TRUE) {
                            global $currencyVars;
                            return $currencyVars[0]['symbolLeft'].sprintf("%.".$currencyVars[0]['decimalPlaces']."f", 0.00).$currencyVars[0]['symbolRight'];
                            
                            } else {
                            
                            return "call for price";
                            
                            }
                            
                            }
                            ?>
                            

                              error msg:

                              Parse error: syntax error, unexpected '<'

                                oops sorry, this is where error is

                                <?
                                echo priceFormat(0);

                                  change <? to <?php or just remove it is already inside a php code block

                                    with <?php or without <?php the following error encounter

                                    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent