Jump to content

Unable to retrieve Service through CustomFieldValue


Jackson Tong

Recommended Posts

I would want to access my product moduleConfigOption1 inside CustomFieldSave hook

add_hook('CustomFieldSave', 1, function($vars) {
  $customFieldValue = \WHMCS\CustomField\CustomFieldValue::firstWhere([
    'fieldid' => $vars['fieldid'],
    'relid' => $vars['relid']
  ]);

  // this works
  $client = $customFieldValue->client;
  $customField = $customFieldValue->customField;
  
  $customFieldValue->service; // this is null
  $customField->product; // null here too
});

According to the document https://classdocs.whmcs.com/8.1/WHMCS/CustomField/CustomFieldValue.html CustomFieldValue has a public property name service, but it's null in my code so I can't do this:

Quote

$customFieldValue->service->product->moduleConfigOption1

 

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.

×
×
  • 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