USD to BTC conversion code So, I have looked everywhere and no one seems to have this specific problem. 

I have set up a e-commerce store that is accepting BTC, So far the users can only see the price of the product in USD, however, I want the user to be able to click the USD price and convert it to BTC instantly. Like you can on a blockchain.info transaction.

For example:

Blockchain transaction conversion

So far, I have only been able to display the BTC price using Blockchain API.

I want the same effect as Blockchain on my price, or atleast under it. 

(Snapshots of site below to give an idea of what I want)

My images

The code I have to display the BTC price (If it helps, im a noob sorry)

&lt;?php

  $url = "https://blockchain.info/stats?format=json";
  $stats = json_decode(file_get_contents($url), true);

  echo $stats['market_price_usd'];

  ?&gt;


Price display:

&lt;p class="Price"&gt;$200.50&lt;/p&gt;
Your question is a bit confusing but it sounds like you are asking how to get a currency amount worth of bitcoin.    


  I want the user to be able to click the USD price and convert it to BTC instantly.    


The answer is simple, division. 

&lt;?php
$url = "https://blockchain.info/stats?format=json";
$stats = json_decode(file_get_contents($url), true);
$btcValue = $stats['market_price_usd'];
$usdCost = 200;

$convertedCost = $usdCost / $btcValue;

echo $convertedCost;
?&gt;     


http://phpfiddle.org/lite/code/cxsk-b62m     


  (If it helps, im a noob sorry)    


That's okay. If you're looking to learn more beginner related Bitcoin coding stuff check out this mega-thread at bitcointalk https://bitcointalk.org/index.php?topic=990348.0  It's mostly PHP and JavaScript examples.