Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/19/2013 in all areas

  1. Thanks to Cody, Tyson and Josh (Serverbin.net) for the code, together they helped get this code working for us the community and here is a little tutorial on how to get this working. Ok firstly you need to download the brand new API which Cody has developed to make it easier for developers from: https://github.com/phillipsdata/blesta_sdk (Click on download zip) Put the files into the root of the Blesta install. Then you need to make a API user and get the hash for the connection to your Blesta install. After you've done that you can do the following, you need to put this on the php file you wish the prices to be displayed on: If you aren't using a SSL on your installation change https://blestainstallationurl.com/api to http://blestainstallationurl.com/api <?php require_once "/home/username/public_html/blesta_api.php"; $user = "API USERNAME"; $key = "API KEY"; $url = "https://blestainstallationurl.com/api/"; $api = new BlestaApi($url, $user, $key); $company_id = 1; // Set acceptable currencies $valid_currencies = array("USD", "GBP", "EUR"); // Set default currency $selected_currency = "USD"; // Set another currency if given if (isset($_GET['currency']) && in_array(strtoupper($_GET['currency']), $valid_currencies)) $selected_currency = strtoupper($_GET['currency']); $price1 = getPackagePrice($api, 1, "month", 1); $price1_amount = formatCurrency($api, $price1->price, $price1->currency, $selected_currency, $company_id); function getPackagePrice($api, $package_id, $period, $term) { $package = $api->get("packages", "get", array('package_id' => $package_id))->response(); $package_price = null; foreach ($package->pricing as $price) { // Get monthly term if ($price->period == $period && $price->term == $term) { return $price; } } return false; } function formatCurrency($api, $amount, $from_currency, $to_currency, $company_id) { // Do the currency conversion $amount = $api->get("currencies", "convert", array('amount' => $amount, 'from_currency' => $from_currency, 'to_currency' => $to_currency, 'company_id' => $company_id))->response(); // Format the currency return $api->get("currencies", "toCurrency", array('value' => $amount, 'currency' => $to_currency, 'company_id' => $company_id))->response(); } ?> You can alter the code for more than one product like the example for mine: <?php require_once "/home/cwadminb/public_html/blesta_api.php"; $user = "CubicWebs_API"; $key = "dbf8a2e7bd87bea1c79d868dba5a56f3"; $url = "https://billing.cubicwebs.com/api/"; $api = new BlestaApi($url, $user, $key); $company_id = 1; // Set acceptable currencies $valid_currencies = array("USD", "GBP", "EUR"); // Set default currency $selected_currency = "USD"; // Set another currency if given if (isset($_GET['currency']) && in_array(strtoupper($_GET['currency']), $valid_currencies)) $selected_currency = strtoupper($_GET['currency']); $price1 = getPackagePrice($api, 1, "month", 1); $price2 = getPackagePrice($api, 2, "month", 1); $price3 = getPackagePrice($api, 3, "month", 1); $price4 = getPackagePrice($api, 4, "month", 1); $price1_amount = formatCurrency($api, $price1->price, $price1->currency, $selected_currency, $company_id); $price2_amount = formatCurrency($api, $price2->price, $price2->currency, $selected_currency, $company_id); $price3_amount = formatCurrency($api, $price3->price, $price3->currency, $selected_currency, $company_id); $price4_amount = formatCurrency($api, $price4->price, $price4->currency, $selected_currency, $company_id); function getPackagePrice($api, $package_id, $period, $term) { $package = $api->get("packages", "get", array('package_id' => $package_id))->response(); $package_price = null; foreach ($package->pricing as $price) { // Get monthly term if ($price->period == $period && $price->term == $term) { return $price; } } return false; } function formatCurrency($api, $amount, $from_currency, $to_currency, $company_id) { // Do the currency conversion $amount = $api->get("currencies", "convert", array('amount' => $amount, 'from_currency' => $from_currency, 'to_currency' => $to_currency, 'company_id' => $company_id))->response(); // Format the currency return $api->get("currencies", "toCurrency", array('value' => $amount, 'currency' => $to_currency, 'company_id' => $company_id))->response(); } ?> Where you wish the price to be put the following php code: <?php echo $price1_amount; ?> Change the number to the product price you wish to display. Again thanks to the coders for helping the community. If you used this code when I posted it please update it as it has a fix from Tyson to ensure the GBP prices don't just change the USD symbol.
    1 point
  2. Hey all, just recently purchased and looking forward on making the change from my current clientexec setup! So, I am working on my integration right now, and of course I would like to show it off and get opinion/suggestions, but I also have a question. Here is the integration: http://foreverfreewebsites.com/test/ This might be nitpicking, but I know I am not alone in wanting to achieve perfection with my designs. If you look at the plugins on the left, they are slightly elevated from the plugins on the right. I have been looking at the CSS and cannot find the culprit for the life of me. Maybe one of you fine savvy folk would be able to help me out?
    1 point
  3. Sorry about that, I was doing some DNS changes when you guys happened to look
    1 point
  4. Paul

    Spam!

    Do you have your email going through a spam filter like Barracuda or Mailfoundry? That would reduce your spam overall, including ticket spam.
    1 point
  5. Gualter

    Speak To Search..

    There are ideas that are a waste of time, and this is one of them. OMG speak to seach lool buy a Iphone and use siri.
    1 point
  6. Tyson

    Speak To Search..

    You can still use the Form component: $this->Form->fieldText("search", "", array('class' => "search", 'x-webkit-speech' => "x-webkit-speech", 'placeholder'=>$this->Html->ifSet($search_options[$this->Html->ifSet($default_search_option, "smart")])));
    1 point
  7. MemoryX2

    Speak To Search..

    This can quickly and easily be changed by changing /app/views/admin/default/structure.pdt: <?php $this->Form->fieldText("search", "", array('class' => "search", 'placeholder'=>$this->Html->ifSet($search_options[$this->Html->ifSet($default_search_option, "smart")]))); ?> to: <input type="text" name="search" value="" class="search" placeholder="Smart Search" x-webkit-speech>
    1 point
  8. I used to play on HomelanFed servers, but they banned me for "cheating". When you play the same map for so long, you pick up on a lot of things, and apparently shooting enemies through walls when you hear them back there is "cheating". Ever since then we had hosted our own CS servers. Turned into a great community, but slowly died down after Source came out.
    1 point
×
×
  • Create New...