I need When Accept a Domain Order Need set Next Due Date to Expired date = same date
I make a Hook not working
<?php
use WHMCS\Database\Capsule;
// Define the hook function
function setDomainExpiryDate($params)
{
// Check if the service is a domain
if ($params['params']['domainid']) {
$domainId = $params['params']['domainid'];
// Retrieve the Next Due Date for the domain
$domainData = Capsule::table('tbldomains')
->where('id', $domainId)
->first();
if ($domainData) {
$nextDueDate = $domainData->nextduedate;
// Update the Expiry Date to match the Next Due Date
Capsule::table('tbldomains')
->where('id', $domainId)
->update([
'expirydate' => $nextDueDate,
]);
}
}
}
// Register the hook with WHMCS
add_hook('AfterModuleCreate', 1, 'setDomainExpiryDate');
?>