Thanks to Luka Svalina for the tip :)
Because I needed the information from within the WHMCS installation, I used the internal API for this problem. The code from Luka Svaldina works, but this was I have more control about what is happening and what information I retrieve.
What I did was use the internal API Get Client Product as described in their documentation, the only downside of this method was that I couldn't set the gid for the products.
$command = "getclientsproducts";
$adminuser = "adminuser";
$values["clientid"] = $_SESSION['uid'];
$results = localAPI($command,$values,$adminuser);
$ca->assign('myVar', $results);
This returns the array for all the active products for that user. This isn't what I have been looking for, but it got me thinking about using it in my advantage.
As the documentation states there you can use the pid to retrieve all the active products for that pid. So I used a getclientsproducts for every pid.
// webhosting product
// Basic Packages
$command = "getclientsproducts";
$adminuser = "adminuser";
$values["clientid"] = $_SESSION['uid'];
$values["pid"] = '19';
$results = localAPI($command,$values,$adminuser);
$ca->assign('basicVPS', $results);
// Standard Packages
$command = "getclientsproducts";
$adminuser = "adminuser";
$values["clientid"] = $_SESSION['uid'];
$values["pid"] = '20';
$results = localAPI($command,$values,$adminuser);
$ca->assign('standardVPS', $results);
// Pro Packages
$command = "getclientsproducts";
$adminuser = "adminuser";
$values["clientid"] = $_SESSION['uid'];
$values["pid"] = '21';
$results = localAPI($command,$values,$adminuser);
$ca->assign('proVPS', $results);
// Elite Packages
$command = "getclientsproducts";
$adminuser = "adminuser";
$values["clientid"] = $_SESSION['uid'];
$values["pid"] = '22';
$results = localAPI($command,$values,$adminuser);
$ca->assign('eliteVPS', $results);
This way every product I need for that page gets his own smarty variable that can be used. But again not exactly what I needed, so I used array_merge_recursive to merge the different arrays into one.
// webhosting product
// set API vars
$command = "getclientsproducts";
$adminuser = "adminuser";
$values["clientid"] = $_SESSION['uid'];
// pid
$values["pid"] = '2';
$results1 = localAPI($command,$values,$adminuser);
$values["pid"] = '5';
$results2 = localAPI($command,$values,$adminuser);
$values["pid"] = '7';
$results3 = localAPI($command,$values,$adminuser);
$values["pid"] = '1';
$results4 = localAPI($command,$values,$adminuser);
$results = array_merge_recursive($results1,$results2,$results3,$results4);
$ca->assign('webHosting', $results);
Exactly what I needed. Until it got me thinking about the creative use of array_merge_recursive in combination with the layout and bootstrap. I created two merged arrays, like this:
$a = array_merge_recursive($results1,$results3);
$b = array_merge_recursive($results2,$results4);
$ca->assign('webHosting_a', $a);
$ca->assign('webHosting_b', $b);
then I used foreach, odd and even to create a modular responsive grid with all the active products for that user. Something roughly like this:
<div class="col-md-12">
<div class="col-md-7>
{foreach $webHosting_a.products.product as $product}
{if $product@iteration is odd}
<a href="/clientarea.php?action=productdetails&id={$product.id}">
<div class="col-md-4">
<div class="panel">
<div class="panel-header">
<h3><strong>{$product.domain}</strong></h3>
</div>
<div class="panel-content">
{if $product.name eq 'Free'}
<meter value="{$product.diskusage}" min=0 max="{$product.disklimit}" low=1 high=3>{$product.diskusage} of {$product.disklimit}</meter>
{elseif $product.name eq 'Premium'}
<meter value="{$product.diskusage}" min=0 max="{$product.disklimit}" low=1 high=3>{$product.diskusage} of {$product.disklimit}</meter>
{elseif $product.name eq 'Professional'}
<meter value="{$product.diskusage}" min=0 max="{$product.disklimit}" low=1 high=3>{$product.diskusage} of {$product.disklimit}</meter>
{else}
<meter value="{$product.diskusage}" min=0 max="{$product.disklimit}" low=1 high=3>{$product.diskusage} of {$product.disklimit}</meter>
{/if}
</div>
<div class="panel-footer">
<h3>{$product.name}</h3>
</div>
</div>
</div>
</a>
{/if}
{/foreach}
<div class="col-md-5">
{foreach $webHosting_b.products.product as $product}
{if $product@iteration is even}
<a href="/clientarea.php?action=productdetails&id={$product.id}">
<div class="col-md-4">
<div class="panel">
<div class="panel-header">
<h3><strong>{$product.domain}</strong></h3>
</div>
<div class="panel-content">
{if $product.name eq 'Free'}
<meter value="{$product.diskusage}" min=0 max="{$product.disklimit}" low=1 high=3>{$product.diskusage} of {$product.disklimit}</meter>
{elseif $product.name eq 'Premium'}
<meter value="{$product.diskusage}" min=0 max="{$product.disklimit}" low=1 high=3>{$product.diskusage} of {$product.disklimit}</meter>
{elseif $product.name eq 'Professional'}
<meter value="{$product.diskusage}" min=0 max="{$product.disklimit}" low=1 high=3>{$product.diskusage} of {$product.disklimit}</meter>
{else}
<meter value="{$product.diskusage}" min=0 max="{$product.disklimit}" low=1 high=3>{$product.diskusage} of {$product.disklimit}</meter>
{/if}
</div>
<div class="panel-footer">
<h3>{$product.name}</h3>
</div>
</div>
</div>
</a>
{/if}
{/foreach}
</div>
</div>
</div>
And of course a bunch of if statements in case the user has only one product to make it all look good :)
Anyhow thanks for the tip Luka!!