Jump to content

Setting Price Value to Text


jtis

Recommended Posts

Hi

 

I have been trying to change the following for my website, so that

when my unit price is "0.00" it will show "call for price" but it don't

seem to work.

 

Base on the codes, the result was it'll show both "0.00" and "call for price"

on my website which is wrong.

 

Would greatly appreciate if anyone can help

 

Thanks in advance

 

priceFormat(0);

 

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

 

if(is_numeric($price)){

 

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";

 

}

 

}

 

Link to comment
Share on other sites

"0" is numeric. Is this what you're after?

function priceFormat($price, $dispNull = FALSE){
    global $currencyVars;

    if(is_numeric($price) && $price != 0){ 
        $price = $price * $currencyVars[0]['value'];
        return $currencyVars[0]['symbolLeft'].sprintf("%.".$currencyVars[0]['decimalPlaces']."f", $price).$currencyVars[0]['symbolRight'];

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

    } else {
        return "Call For Price";

    }

}

Link to comment
Share on other sites

Hi

 

Thanks, had tried updating and uploaded the scripts.

 

and the result is "call for price" appear twice.

 

attached herewith the result for your reference.

 

Thanks again for your help

post-133654-13482403476122_thumb.jpg

Link to comment
Share on other sites

hi

 

I notice that when the sales price is "0.00" it will also show

"call for price" which i think it should be blank.

 

would appreciate if anyone can help.

 

following are the codes for sales price and price format

 

function salePrice($normPrice, $salePrice){

 

global $config;

 

if($config['saleMode']==1){

 

if($salePrice<$normPrice && $salePrice>0){

 

return $salePrice;

 

} else {

 

return FALSE;

 

}

 

} elseif($config['saleMode']==2) {

 

$saleValue = $normPrice * ((100-$config['salePercentOff'])/100);

 

if($saleValue<$normPrice && $saleValue>0){

return $saleValue;

} else {

return FALSE;

}

 

} else {

return FALSE;

}

}

 

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

global $currencyVars;

 

if(is_numeric($price) && $price != 0){

 

 

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

 

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

 

} elseif($dispNull == TRUE) {

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

 

} else {

 

return "Call For Price";

 

}

 

}

 

Thanks in advance

Link to comment
Share on other sites

hi

 

thanks but the result is still the same

 

it still show "call for price" twice

when the retail price is "0.00" it should show "call for price"

when the sales price is "0.00" it should be blank

 

appreciate if you could help.

 

thanks in advance

Link to comment
Share on other sites

Never mind, I guess my suggestion doesn't really fix the problem. What are you doing with the global variable outside of the function?

 

In your original post, the variable was inside the is_numeric if test:

 

<?php
//...

if(is_numeric($price)){

global $currencyVars;

//...
?>

 

Does the duplicate label come from having it above the if?

 

<?php
//...

global $currencyVars;
   
if(is_numeric($price) && $price != 0){

//...
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.