Jump to content

Detect if user has specific product


Recommended Posts



I am looking for a way to detect if a client has a certain product and if so select a custom field from that product for use in templates.


For example: Display certain information only to clients with a particular product in their sidebar.


Thanks in advance.

Link to comment
Share on other sites

The detailed product information isn't available on every page so if your adding something like this to the sidebar you will need to use custom php code inside of the sidebar/header template to get the information from the WHMCS database.


Something like this should work, just replace packageid=1 which the package id you are looking for and fieldid=1 with the custom field you are looking for.



$userid = $this->_tpl_vars['clientsdetails']['id'];

$result = mysql_query("SELECT id FROM tblhosting WHERE packageid=1 and userid =$userid");

$data = mysql_fetch_array($result);

if ($data != false) {

$this->_tpl_vars['has_package'] = true;


// get the custom field

$result = mysql_query("SELECT value FROM tblcustomfieldsvalues WHERE fieldid=1 and relid=".$data['id']);

$data = mysql_fetch_array($result);

$this->_tpl_vars['custom_product_field'] = $data['value'];


else {

$this->_tpl_vars['has_package'] = false;




{if $has_package}



Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

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

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