Bets Posted September 20, 2018 Share Posted September 20, 2018 Hello, I want get a list of products/services that have the customer ( like a clientarea.php?action=services page ). Where exactly are this informations on database? I followed the exemple on https://whmcs.community/topic/263133-retrieving-product-pricing-information-using-capsule/?tab=comments#comment-1209905 , worked pretty. But i have no idea where is this informations. Can give me a example plz? Thank you guys :) 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 21, 2018 Share Posted September 21, 2018 16 hours ago, Bets said: Can give me a example plz? a better example hook might be the hhread below - i'm going to assume that this is for a client area page and that the client is already logged in. <?php # Product/Service List Hook # Written by brian! use Illuminate\Database\Capsule\Manager as Capsule; function products_list_hook($vars) { $client = Menu::context('client'); $services = Capsule::table('tblhosting') ->join('tblproducts','tblhosting.packageid','=','tblproducts.id') ->where('userid',$client->id) ->select('tblhosting.*','tblproducts.name as product') ->orderby('nextduedate','desc') ->get(); $results = json_decode(json_encode($services), true); return array("myservices" => $results); } add_hook("ClientAreaPage", 1, "products_list_hook"); ?> a clients product/services are stored in the tblhosting table - that will give you the majority of the information you want... however, it wouldn't give you the Product Name of the service, and so for that we need to check the tblproducts table - that is basically all the above hook is doing... it's creating that list and then passing it back to the template as an array. and then in the template, you would output that array - that could be using a foreach loop, using DataTables (as I did in the example above), in a HomePagePanel etc. 0 Quote Link to comment Share on other sites More sharing options...
Bets Posted September 21, 2018 Author Share Posted September 21, 2018 Hello, I used another way, unsing internal api: $command = 'GetClientsProducts'; $postData = array( 'clientid' => $ca->getUserID(), 'stats' => true, ); $resultArray = localAPI($command, $postData); global $smarty; $products = $resultArray['products']['product']; $smarty->assign("products", $products); In the custom.tpl {foreach $products as $product} <a class="dropdown-item" href="?p={$product.name}&usr={$product.username}&ip={$product.serverip}&porta={$product.customfields.customfield[0].value}&tec={$product.customfields.customfield[1].value}&step=two">{$product.name} ( {$product.username} )</a> {/foreach} But thank you for the example. 🙂 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.