Skip to content

Instantly share code, notes, and snippets.

@jbmadking
Created March 6, 2016 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbmadking/57789210c7867472a881 to your computer and use it in GitHub Desktop.
Save jbmadking/57789210c7867472a881 to your computer and use it in GitHub Desktop.
<?php
/**
* API function
* Get domain pricing
* includes/api/getdomainpricing.php
*/
if (!defined("WHMCS")) {
die("This file cannot be accessed directly");
}
$apiresults = ['result' => 'error', 'message' => 'No Result found'];
$query = "SELECT tblpricing.currency, tblpricing.msetupfee, tblpricing.qsetupfee, tblpricing.ssetupfee,
tblpricing.asetupfee, tblpricing.bsetupfee, tblpricing.monthly, tblpricing.quarterly,
tblpricing.semiannually, tblpricing.annually, tblpricing.biennially,
(
SELECT tblcurrencies.prefix
FROM tblcurrencies
WHERE id = tblpricing.currency
) AS curprefix,
(
SELECT tblcurrencies.suffix
FROM tblcurrencies
WHERE id = tblpricing.currency
) AS cursuffix,
(
SELECT tbldomainpricing.extension
FROM tbldomainpricing
WHERE id = tblpricing.relid
) AS tld
FROM tblpricing
WHERE tblpricing.type= 'domainregister'
AND !(
SELECT tbldomainpricing.extension
FROM tbldomainpricing
WHERE id = tblpricing.relid
)";
try {
$satement = mysql_query($query);
$domains = [];
while($row = mysql_fetch_assoc($satement)) { $domains[] = $row; }
$apiresults = ['result' => 'success', 'domain_pricing' => $domains];
} catch (Exception $e){
$apiresults = ['result' => 'error', 'message' => $e->getMessage()];
echo json_encode($apiresults);
die();
}
echo json_encode($apiresults);
die();
@jbmadking
Copy link
Author

This is a simple script to get WHMCS domain pricing through the API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment