Answer the question
In order to leave comments, you need to log in
How to discount a product in an Opencart template using PHP?
I want to manually make a 3% discount on a product and display the finished result with a 3% discount under the price in the template.
I take the $price price variable and write the code in the template:
$price = 6457;
<?php echo $price * 0.03; ?>
Answer the question
In order to leave comments, you need to log in
First, if you run your code, the result will be 193.71, and 0.18. Check that your price contains exactly what you wrote.
Secondly, your discount formula is wrong. You calculate 3% and you need to decrease the price by 3%. For example, like this:
Well, in the template later
$salePrice = $price - ($price/100*3);
= $salePrice
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question