whmdev Posted September 9, 2019 Share Posted September 9, 2019 I was looking at this page which has many properties and methods related to Product. https://classdocs.whmcs.com/7.8/WHMCS/Product/Product.html How can I retrieve properties of any product if I know product ID? There doesn't seem to be any function like getProductDetail($product_id) on above page so any PHP example will be really helpful. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 10, 2019 Share Posted September 10, 2019 21 hours ago, whmdev said: How can I retrieve properties of any product if I know product ID? https://docs.whmcs.com/Using_Models use WHMCS\Product\Product; $pid = 45; $product = Product::find($pid); $productname = $product->name; 21 hours ago, whmdev said: There doesn't seem to be any function like getProductDetail($product_id) on above page so any PHP example will be really helpful. to get product info like this you basically have 3 options... class models, API or SQL query. using Models, you could use... $decodedata = json_decode(json_encode($product), true); to access the result as an array (if you're more familiar with handling the results that way).... using the API - https://developers.whmcs.com/api-reference/getproducts/ and the SQL query would use capsule to search the tblproducts database table... posted similar queries many times previously. 0 Quote Link to comment Share on other sites More sharing options...
whmdev Posted September 10, 2019 Author Share Posted September 10, 2019 Thanks for the excellent explanation 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.