Jump to content

Specific Custom Field Value Print in Invoice


serverbd

Recommended Posts

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 by pRieStaKos
Link to comment
Share on other sites



$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?

Link to comment
Share on other sites

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 by pRieStaKos
Link to comment
Share on other sites

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');
        }
    }
}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated