Jump to content

How to get product detail based on ID


whmdev

Recommended Posts

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)....

Kuz4ySr.png

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated