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

Link to comment
Share on other sites

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