Jump to content

[SOLVED] if statements


jakebur01

Recommended Posts

hey my little shipping calculation has been working fine recently. But, I noticed that when you carts total is 3,534.99 it returns 5.99 for some odd reason. Could someone help me perfect this?

 

function calculate_shipping_cost()
{

// return 20.00;
  
$t_number =   number_format($_SESSION['total_price'],2);
  
if ($t_number >= 0.01 and $t_number <= 14.99) {
return 5.99;
}

else if ($t_number >= 15.00 and $t_number <= 29.99) {
return 8.99;
}
  
else if ($t_number >= 30.00 and $t_number <= 49.99) {
return 10.99;
}

else if ($t_number >= 50.00 and $t_number <= 74.99) {
return 12.99;
}

else if ($t_number >= 75.00 and $t_number <= 99.99) {
return 14.99;
}

else if ($t_number >= 100.00 and $t_number <= 149.99) {
return 16.99;
}
  
else if ($t_number >= 150.00 and $t_number <= 199.99) {
return 18.99;
}
  
else if ($t_number >= 200.00 and $t_number <= 299.99) {
return 21.99;
}

else if ($t_number >= 300.00 and $t_number <= 5000.00) {
return 28.99;
}
  
else {
return 10.00;
} 
  
}

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.