serverbd Posted August 31, 2021 Share Posted August 31, 2021 Blew code giving me all custom filed value .. but I need only One specific field value . My field name CLIENTCODE and field ID 12 if ($customfields) { foreach ($customfields AS $customfield ) { $tblhtml .= $customfield['value']; } } 0 Quote Link to comment Share on other sites More sharing options...
pRieStaKos Posted September 1, 2021 Share Posted September 1, 2021 (edited) 12 hours ago, serverbd said: Blew code giving me all custom filed value .. but I need only One specific field value . My field name CLIENTCODE and field ID 12 if ($customfields) { foreach ($customfields AS $customfield ) { $tblhtml .= $customfield['value']; } } There are different customfields on WHMCS (https://docs.whmcs.com/Custom_Fields). If you mean client custom fields, you can try this: $client = Client::findOrFail($clientid); foreach ($client->customFieldValues as $cf) { // Check client customField exists if ($cf->value && $cf->customField->fieldName == "CLIENTCODE") { $clientCode = $cf->value; } } or use {$client_custom_field_fieldnamehere} on tpl, as mentioned in referenced page. Edited September 1, 2021 by pRieStaKos 0 Quote Link to comment Share on other sites More sharing options...
serverbd Posted September 1, 2021 Author Share Posted September 1, 2021 Error: Class 'Client' not found in /templates/six/invoicepdf.tpl:151 0 Quote Link to comment Share on other sites More sharing options...
pRieStaKos Posted September 1, 2021 Share Posted September 1, 2021 1 minute ago, serverbd said: Error: Class 'Client' not found in /templates/six/invoicepdf.tpl:151 You cannot add hook code to invoicepdf.tpl. Use {$client_custom_field_fieldnamehere} 0 Quote Link to comment Share on other sites More sharing options...
serverbd Posted September 1, 2021 Author Share Posted September 1, 2021 $customfields its a array ... and when print foreach ($customfields AS $customfield ) { $tblhtml .= $customfield['value']; } its showing one single users all custom field.. so if I call with a filed name or field id .. is it show me only exact one custom filed data .. can u make the code? or how can I var_dump or print_r $customfields inside invoice to see all the array value? 0 Quote Link to comment Share on other sites More sharing options...
pRieStaKos Posted September 1, 2021 Share Posted September 1, 2021 (edited) 10 minutes ago, serverbd said: $customfields its a array ... and when print foreach ($customfields AS $customfield ) { $tblhtml .= $customfield['value']; } its showing one single users all custom field.. so if I call with a filed name or field id .. is it show me only exact one custom filed data .. can u make the code? or how can I var_dump or print_r $customfields inside invoice to see all the array value? In invoicepdf.tpl: if ($customfields) { $pdf->Ln(); foreach ($customfields as $customfield) { if ($customfield['id'] == 12) || $customfield['fieldname'] == "CLIENTCODE") { $pdf->Cell(0, 4, $customfield['fieldname'] . ': ' . $customfield['value'], 0, 1, 'L'); } } } This should show only the customfield, if ID is 12 or Field Name is CLIENTCODE. Other customfields, no. Quote or how can I var_dump or print_r $customfields inside invoice to see all the array value? {$customfields|print_r} Edited September 1, 2021 by pRieStaKos 1 Quote Link to comment Share on other sites More sharing options...
serverbd Posted September 1, 2021 Author Share Posted September 1, 2021 Yes its working.. Thanks for you help mate.. if ($customfields) { $pdf->Ln(); foreach ($customfields as $customfield) { if ($customfield['fieldname'] == "CLIENTCODE") { $pdf->Cell(0, 4, $customfield['fieldname'] . ': ' . $customfield['value'], 0, 1, 'L'); } } } 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.