I am trying to find a way to get a product id in complete.tpl in whmcs.
Basically, instead of having a default button for continue to client area, I need to replace it with continue to product detail that the client has just purchased.
uri will look something like this: https://[HOSTNAME]/clientarea.php?action=productdetails&id=225
I checked the builtin hooks and I do see ShopingCartCheckoutCompletedPage which sends the variable in complete.tpl but I cant find product id details there.
This is what I tried:
add_hook('ShoppingCartCheckoutCompletePage', 1, function($vars) {
/**
* select packageid from whmcs_db.tblinvoiceitems, whmcs_db.tblhosting WHERE whmcs_db.tblinvoiceitems.relid = whmcs_db.tblhosting.id and whmcs_db.tblinvoiceitems.type = 'Hosting'
and whmcs_db.tblinvoiceitems.invoiceid = '27';.
*/
$ordernumber = $vars['ordernumber'];
$orderid = $vars['orderid'];
$invoiceid = $vars['invoiceid'];
$productid = Capsule::table('tblinvoiceitems')
->join('tblhosting', 'tblinvoiceitems.relid', '=', 'tblhosting.id')
->where('tblinvoiceitems.invoiceid','=', $invoiceid)
->where('tblinvoiceitems.type', '=', 'Hosting')
->select('tblhosting.packageid')
->get();
return $productid;
});
Above query is not working, but when I pass hardcoded value its showing properly in complete.tpl can someone please help?
Thanks