Jump to content

[SOLVED] Making a function for a product discount


darkfreaks

Recommended Posts

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 
;}?>

<?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;

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.