Filzhut.net Filzhut.net amazon_functions for PHP (Version 0.9)
Making the work with Amazon.com™ Web Services Version 1.0 much easier

amazon_calculate_savings (Version 0.903 and higher)

Calculates the savings on a reduced product

array amazon_calculate_savings(var ListPrice, var OurPrice)

With this function you can calculate the savings on a reduced product. ListPrice has to be the official price and OurPrice has to be the reduced price. The functions returns an array with the saved sum and the saved percentage. If there were no savings (ListPrice=OurPrice) or the submitted prices were invalid, the returned values are empty.

Example 1. Get savings for a product:

$Savings=amazon_calculate_savings("3.99$","1.49$");

if($Savings[0]) {
  echo "You saved $Savings[0]$ ($Savings[1]% off)."; // Would return "You saved 2.50$ (62% off)."
 }
else {
  echo "You saved nothing.";
 }


© by Filzhut.net, Daniel Filzhut 2002