Jump to content

how to convert from dollar to cents


Recommended Posts


Hi there

how can i convert the dollar amount to cents eg i want to convert 1.00 to 100 cents.

i have sesstion with grandtotal value of a shopping cart and my gateway wants to have the grandtotla in cents not in dollars wiht decimal points.

this is my session varible .

<?php
if (!session_id()) session_start();
if(($shoptill->GrandTotal() != "")) {
$_SESSION["grandtotal"] = "".$shoptill->GrandTotal() ."";
}
?>


the help is greatly appreciated

Link to comment
Share on other sites

[!--quoteo(post=337509:date=Jan 17 2006, 06:55 PM:name=khan kaka)--][div class=\'quotetop\']QUOTE(khan kaka @ Jan 17 2006, 06:55 PM) [snapback]337509[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Hi there

how can i convert the dollar amount to cents eg i want to convert 1.00 to 100 cents.

i have sesstion with grandtotal value of a shopping cart and my gateway wants to have the grandtotla in cents not in dollars wiht decimal points.

this is my session varible .

<?php
if (!session_id()) session_start();
if(($shoptill->GrandTotal() != "")) {
$_SESSION["grandtotal"] = "".$shoptill->GrandTotal() ."";
}
?>
the help is greatly appreciated
[/quote]


Perhaps I'm missing something. Perhaps I'm crazy. But you can use the function below to perform that calculation. Took me just over two hours to write.

function getCents($dollars)
{
$cents = $dollars * 100;
return $cents;
}

If you want to use it for real, it's $29.95 plus tax. I accept Visa, Mastercard, Discover, and Diner's Club.
Link to comment
Share on other sites

  • 1 month later...
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.