Home > Enterprise >  Value Subtraction Script for PHP Variable
Value Subtraction Script for PHP Variable

Time:04-03

I would like a Value Subtraction Script, For Discount in REAL.

Example: the Customer makes a Purchase of $140.00 (Registered in the DB), on the Checkout Page, I want to print a Discount of $10.00

So that the value of $130.00 appeared to him, how could I do that with a simple script in PHP

<?=number_format($order[0]->total_order_value, 2, ',', '.'); ?>

//$140,00 to 130,00

How to do this magic with simple script inside this variable?

CodePudding user response:

Just do the subtraction in the argument to number_format()

<?php $discount = 10; echo number_format($order[0]->total_order_value - $discount, 2, ',', '.'); ?>
  • Related