hello again all,
almost have an e-commerce site up that is based on drupal + ubercart - the bitcoind part has been solved (based on the results of my previous post). now I am looking at implementing a feature to change the price of our products based on the value of bitcoins at the moment someone places an order (heck, even when viewing the product [catalog] would be nice). the module '<a href="http://drupal.org/project/uc_custom_price>uc_custom_price' looks to be the way to implement/handle this... I am still learning drupal's in's-and-out's, so I come here hoping some kind soul may be able to help out.
this is my pseudo-code, that I am wanting to implement using 'uc_custom_price' module ::
- $CURRENT_PRODUCT_VALUE = x
- $CURRENT_BITCOIN_VALUE = x (obtained from mtgox (+ others?))
- add % markup to PRODUCT_VALUE => hold value in $MARKUP_PRICE variable
- $MARKUP_PRICE divided by $CURRENT_BITCOIN_VALUE = 'FINAL BTC PRICE' for product
from there, we'd like to display the 'FINAL BTC PRICE' for each product in our product catalog. I hope someone may be able to assist, and/or when I do come up with the final code, I will post here for others to use as well/learn from.
thanks much,
-agentdcooper

Comments
all fixed now
here's an update: I was able to get this operational in ubercart by coding a perl script, which is runs every 5minutes via cron, that query's mtgox's ticker.php script to obtain the current bitcoin value in USD ('last') [note: one could do this several other ways, of them being telnet'ing to bitcoincharts.com on port: 27007 to extract the live trade data]
we use the following php code in the 'custom price calculation' field in ubercart (from: uc_custom_price module):
$product = file_get_contents("product.txt");$gox = file_get_contents("gox.txt");
$productfull = t($product) / .98;
$price = t($productfull)/t($gox);
$item->price = t($price);
(not sure if all those "t"'s are required, but figured better to be safe then sorry - and it does work)
with the above, this gets things working up to a point that when someone clicks 'add to cart' the cart then displays the "custom price" -> ONLY the cart shows the custom price (figured that was worth repeating). to "fix" ubercart so that when viewing the price anywhere on the site, we found/implemented a patch for 'uc_custom_price' module by vishun which does just that = all "price" displays show the 'uc_custom_price' instead of the default price configured within ubercart.
all is well, hope this helps someone else looking to setup a bitcoin-based e-commerce site down the road!
-agentdcooper