Avail the reduced price for a product

The desired outcome is to adjust the Total based on the Discount percentage applied to the input Sub-Total. For instance, if the Sub-Total is $100 and a 10% Discount is applied, the Total should be $90. However, there seems to be an error in the given example. To resolve this issue, the correct approach is to use the following syntax: $total = 8999999. This serves as a solution to the Discount calculation problem, and the provided code is just an illustrative example.


To obtain a discount on a product, I am able to access the old and new prices through visual composer. While I can retrieve these values, I am unable to perform calculations on them. Both the old and new prices are whole numbers, but when I divide the old price by the new price, I receive a decimal value such as 60.929323229329. Afterwards, I am required to round this number and subtract it from 100. Unfortunately, this process is not yielding the desired results.

The result must be for instance 39%


I’m unclear on what you’re referring to when you mention ‘discount.’ If you’re looking for the percentage, it will be displayed.

Frequently Asked Questions

Posted in Php