Skip to content

Instantly share code, notes, and snippets.

@aklimaruhina
Created October 23, 2022 10:58
Show Gist options
  • Save aklimaruhina/c21c2ccede3d9758d140bbee86296848 to your computer and use it in GitHub Desktop.
Save aklimaruhina/c21c2ccede3d9758d140bbee86296848 to your computer and use it in GitHub Desktop.
When you need to find your sell price along with discount price
function getSalePrice($reg_price, $dis_amount, $dis_type) {
if($dis_type){
// if discount amount percentage(%)
$sale_price = (float)$reg_price - ((float)$reg_price * (float)$dis_amount/100);
$sale_price = round($sale_price, 2);
} else{
// if discount amount fixed
$sale_price = (float)$reg_price - (float)$dis_amount;
}
return $sale_price;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment