darkfreaks Posted September 29, 2007 Share Posted September 29, 2007 okay so im trying to make it if the category equals necklace and the product id returns with the word necklace the product price will be discounted on checkout. <?php if($cat=="necklaces"||$prodid= strpos("necklace",$prodid,TRUE)) { $productprice=///$productprice discounted at 10 percent off ;}?> Link to comment https://forums.phpfreaks.com/topic/71182-solved-making-a-function-for-a-product-discount/ Share on other sites More sharing options...
BlueSkyIS Posted September 29, 2007 Share Posted September 29, 2007 uh... $productprice = $productprice * .9; // 10% discount Link to comment https://forums.phpfreaks.com/topic/71182-solved-making-a-function-for-a-product-discount/#findComment-358030 Share on other sites More sharing options...
marcus Posted September 29, 2007 Share Posted September 29, 2007 <?php $string = "i love necklaces"; $string2 ="i love potatoes!"; if(preg_match("/necklace/i",$string)){ echo "String 1 has \"necklace\""; }else { echo "String 1 does not have \"necklace\""; } echo "<br><br>\n"; if(preg_match("/necklace/i",$string2)){ echo "String 2 has \"necklace\""; }else { echo "String 2 does not have \"necklace\""; } ?> Example. $productprice = 100; $discount = .1; $productprice = $productprice - ($productprice*$discount); echo $productprice; Link to comment https://forums.phpfreaks.com/topic/71182-solved-making-a-function-for-a-product-discount/#findComment-358033 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.