Dynamic Prices for a product which changes every hour
I am running a silver bullion website. The price of silver changes every hour. The silver price is stored in a variable. I am searching for a shopping cart for wordpress that can do the following things:
For example I have a product name Silver Coin:
Silver Selling price at the present hour is $25.5 ---> The cart Should pick this value from a PHP variable But dont output it as actual price of th开发者_开发知识库e product
The product price will be 1.2% of $25.5 ----------------> This Should be the actual price of product and output as the product price
How to get this functionality and with which shopping cart? I am using WP-eCommerce Plugin, anyone can help please.
I did something similar not long ago and it was fairly straight forward.
- Create a function in your themes function.php file which returns the latest price of silver. If you only want to pull it in every hour then this function could check a time stamp of when it was last retrieved and then either return the price from the database or retrieve the new price and update the database.
- WP-eCommerce supports templates, find the correct template file which displays your products and inside the loop where the price is being displayed replace their function call with your own. I think the function is called, wpsc_the_product_price()
If for example some of your prices are 1.5% of the silver price and others are 1.2% then you could set the percentage in the product price. Then instead of replacing the function call in the template file use it to retrieve the product percentage and along with your silver price calculate the product price.
精彩评论