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 ;}?> Quote 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 Quote 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; Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.