Get up to 10% Discount by paying in South African Rand with PAYFAST
<?php
$original_amount = edd_get_cart_total( $discounts );
$from_currency = ‘USD’;
$to_currency = ‘ZAR’;
$apikey = ’59e32f684f191c163232′;
$from_Currency = urlencode($from_currency);
$to_Currency = urlencode($to_currency);
$query = “{$from_Currency}_{$to_Currency}”;
$json = file_get_contents(“https://free.currencyconverterapi.com/api/v6/convert?q=USD_ZAR,USD_BTC&compact=ultra&apiKey=59e32f684f191c163232”);
$obj = json_decode($json, true);
$valUSD = floatval($obj[“USD_ZAR”]);
$valBTC = floatval($obj[“USD_BTC”]);
$new_currency_total_USD = $valUSD * $original_amount;
$new_currency_total_BTC = $valBTC * $original_amount;
echo”<p>The cart will automatically convert your total at the current exchange rate.</p>
<p>Simply select ‘PAYFAST’ as your payment method.</p>”;
echo “Your Cart Total: $” . $original_amount .”<br>”;
echo “$” . $original_amount . ” is (Rand) ZAR ” . number_format($new_currency_total_USD, 2, ‘.’, ”);
echo “<br>”;
$amounttoremove = ($original_amount / 100) * 10;
$discountamount = $original_amount – $amounttoremove;
$discountamount = number_format($discountamount, 2, ‘.’, ”);
echo “<br>”;
echo “With the discount you will pay approximately: $” . $discountamount;
echo “<br>”;
echo “<br>”;
?>