fubarur Posted November 27, 2006 Share Posted November 27, 2006 Hey all,Trying to set this up to grab the subtotal and if it's larger than $50 to display "Free Shipping"[code] php: <?php if (Environment::number_format(CartSession::subtotal_cost()) >= '$50') echo "Free Shipping"; ?>[/code]This code works fine from $0-$99so for $0-$49.00 nothing is diplayedfor $50-$99.99 "Free Shipping" is diplayedbut $100.00 on up it will not display "Free Shipping"Any ideas? Link to comment https://forums.phpfreaks.com/topic/28664-i-have-a-question-regarding-an-if/ Share on other sites More sharing options...
kenrbnsn Posted November 27, 2006 Share Posted November 27, 2006 Remove the dollar sign and the quotes. Treat the value as a number.You are currently comparing strings and the string '$100.00' is not greater than the string '$50'.Ken Link to comment https://forums.phpfreaks.com/topic/28664-i-have-a-question-regarding-an-if/#findComment-131165 Share on other sites More sharing options...
fubarur Posted November 27, 2006 Author Share Posted November 27, 2006 Nope that will not work the number spit out from "Environment::number_format(CartSession::subtotal_cost())" would look like $50 so without the $ it can not compare it.any other ideas? Link to comment https://forums.phpfreaks.com/topic/28664-i-have-a-question-regarding-an-if/#findComment-131174 Share on other sites More sharing options...
kenrbnsn Posted November 27, 2006 Share Posted November 27, 2006 Then remove the $ from that number:[code]<?php if (str_replace('$','',Environment::number_format(CartSession::subtotal_cost())) >= 50) echo "Free Shipping";?>[/code]Ken Link to comment https://forums.phpfreaks.com/topic/28664-i-have-a-question-regarding-an-if/#findComment-131179 Share on other sites More sharing options...
fubarur Posted November 27, 2006 Author Share Posted November 27, 2006 Beautiful! it seems to work! Thanks Link to comment https://forums.phpfreaks.com/topic/28664-i-have-a-question-regarding-an-if/#findComment-131196 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.