DigItalWarrior Posted October 16, 2016 Share Posted October 16, 2016 Hi all, any method to get product by 'name' and not by 'pid' via external API? 0 Quote Link to comment Share on other sites More sharing options...
payless4domains Posted October 17, 2016 Share Posted October 17, 2016 Hi DigitalWarrior, You could try this by saving it in your hooks folder and naming as myproducts.php, changing the case, info sections to your product info and removing my notes. I haven't tested it but is should work. Hopefully I've understood you correctly to what you are after. <?php add_hook( 'ClientAreaPage', 1, function( $vars ) { $user = Menu :: context( 'client' ); $data = array( 'showproductdata' => false ); if (! $user ) return $data; $products = localAPI( 'getclientsproducts', array( 'clientid' => $user->getAttribute( 'id' ), ), 'admin' ); if (! $products || $products['result'] != 'success' || $products['totalresults'] == 0 || count( $products['products'] ) == 0 ) return $data; $data['showproductdata'] = true; $product = $products['products']['product'][0]; $info = null; $title = $product['translated_name']; switch( $product['pid'] ) : case '1' : //change to the 1st product id $info = 'productname1'; //change to the product name break; case '2' : //change to the 2nd product id $info = 'productname2'; //change to the product name break; case '3' : //change to the 3rd product id $info = 'productname3'; //change to the product name break; endswitch; $data['myproduct'] = array( 'info' => $info, 'title' => $title); return $data; }); 0 Quote Link to comment Share on other sites More sharing options...
DigItalWarrior Posted October 20, 2016 Author Share Posted October 20, 2016 Hello payless4domains and thank you for your support. Unfortunately I'm really new in WHMCS and I dont know how to use hooks. I need to learn more about whmcs and any help is really appreciated. Thank you again 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted October 20, 2016 Share Posted October 20, 2016 Hi all,any method to get product by 'name' and not by 'pid' via external API? it's not possible using WHMCS API, but you may write your own API file that will query database and work how you need it to work 0 Quote Link to comment Share on other sites More sharing options...
DigItalWarrior Posted October 20, 2016 Author Share Posted October 20, 2016 Hey sentq, thank you for your reply. Any code example or docs available or how to? 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted October 20, 2016 Share Posted October 20, 2016 there is no official documentation for what you need to do, but here is how you can interact with the database http://docs.whmcs.com/Interacting_With_The_Database and this http://docs.whmcs.com/Creating_Pages 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.