xedro99 Posted September 29, 2018 Share Posted September 29, 2018 Hey there everyone, I am currently having trouble in fetching data from the mysql table from the WHMC's database, the table is of a whmcs addon and till not I have used this hook to fetch the data <?php # Get Product Group PIDs Hook # Written by brian! use Illuminate\Database\Capsule\Manager as Capsule; function get_productIDs_for_specified_groups_hook($vars) { if ($vars['templatefile'] == 'products') { $gid = $_SESSION['products']['pid']; $hour = Capsule::table('mod_hb_products')->whereIn('product_id',$gid)->pluck('hourly_cost'); return array("hourlyprice" => $hour); } } add_hook('ClientAreaPageCart', 1, 'get_productIDs_for_specified_groups_hook'); ?> and placed this in the template file (tpl) $hourlyprice but instead of displaying the database value it just displays Array in the tpl, also I want it to fetch the data for universal use within the whmcs templates, not just a single template. any help would be appreciated. 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted September 30, 2018 Share Posted September 30, 2018 pluck() returns an array. In your case an array with auto index therefore {$hourlyprice.0} will return your value. That said, if you already know that the first match is okay or if you expect the query to return one value, use first() instead of pluck(). This way {hourlyprice} contains your value. 1 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.