traxwriter Posted June 1, 2012 Share Posted June 1, 2012 Hi, 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. 0 Quote Link to comment Share on other sites More sharing options...
jclarke Posted June 3, 2012 Share Posted June 3, 2012 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. {php} $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; } {/php} {if $has_package} {$custom_product_field} {/if} 0 Quote Link to comment Share on other sites More sharing options...
traxwriter Posted June 13, 2012 Author Share Posted June 13, 2012 Thanks for, just what I was looking for. Much appreciated. 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.