Home » Php » Calculate sale price taking the final price with discount in PHP

# Calculate sale price taking the final price with discount in PHP

Questions:

I have a purchase price, then I increase the 20% profit. The problem is that if my supplier makes a 5% discount on the purchase, then I discount that 5% discount at my normal purchase price and this new discount purchase price will boost the 20% profit. But I can not calculate the normal sale price.

Discount: 5%

Profit: 20%

372.93 – Purchase price without discount.

354.29 – Purchase price with discount.

?????? – Sale price.

425.15 – Sale price with Profit.

This is my PHP code:

``````<?php
\$discount = 5;
\$profit = 1.20;
\$purchase = 372.93;

\$product_purchase = \$purchase - (\$purchase * (\$discount / 100)); // 354.2835
\$product_sale = 0; //??????????
\$product_sale_final = \$product_purchase*\$profit; //425.1402

echo "Purchase: ".\$product_purchase."<br>";
echo "Product Sale: ".\$product_sale."<br>";
echo "Product Sale Final: ".\$product_sale_final."<br>";
echo "Discount: ".\$discount."%";
?>
``````

I hope someone can help me, I have many hours trying to find the answer. Thank you very much!