cluster Posted Wednesday at 09:40 AM Share Posted Wednesday at 09:40 AM Would it be possible to hide date range in invoice emails (only for new domain orders)? By default "Expiry Date" should be empty if a NEW domain name order is received e.g. 00/00/0000 Following hook removes the date range for all invoices ... I just want to remove the date for "Domain name" items and only when the "Expiry Date" is 00/00/0000. https://github.com/Katamaze/WHMCS-Action-Hook-Factory/blob/master/hooks/noDatesInInvoiceItemsDescription.php It doesn't work with the Smarty email templates, so, I’d like to apply a similar condition into this hook ... any idea? {if $domain_expiry_date eq "00/00/0000"} <?php /** * No Dates in Invoice Items Description * * @package WHMCS * @copyright Katamaze * @link https://katamaze.com * @author Davide Mantenuto <info@katamaze.com> */ use WHMCS\Database\Capsule; add_hook('InvoiceCreationPreEmail', 1, function($vars) { $items = Capsule::table('tblinvoiceitems')->select('id', 'description')->where('invoiceid', '=', $vars['invoiceid'])->get(); if (!$items) { return; } $dateFormat = Capsule::table('tblconfiguration')->select('value')->where('setting', '=', 'DateFormat')->first(); if (in_array($dateFormat->value, [ 'DD/MM/YYYY', 'DD.MM.YYYY', 'DD-MM-YYYY' ])) { $regex = '/[" "][(](((0[1-9]|[12][0-9]|3[01])[- \/.](0[13578]|1[02])|(0[1-9]|[12][0-9]|30)[- \/.](0[469]|11)|(0[1-9]|1\d|2[0-8])[- \/.]02)[- \/.]\d{4}|29[- \/.]02[- \/.](\d{2}(0[48]|[2468][048]|[13579][26])|([02468][048]|[1359][26])00))[\w -]*[-]*[\w -](((0[1-9]|[12][0-9]|3[01])[- \/.](0[13578]|1[02])|(0[1-9]|[12][0-9]|30)[- \/.](0[469]|11)|(0[1-9]|1\d|2[0-8])[- \/.]02)[- \/.]\d{4}|29[- \/.]02[- \/.](\d{2}(0[48]|[2468][048]|[13579][26])|([02468][048]|[1359][26])00))[)]/'; } elseif ($dateFormat->value == 'MM/DD/YYYY') { $regex = '/[" "][(](((0[13578]|1[02])|(0[1-9]|[12][0-9]|30)[-\/.](0[469]|11)|(0[1-9]|1\d|2[0-8])[-\/.]02)[-\/.](0[1-9]|[12][0-9]|3[01])[-\/.]\d{4}|29[-\/.]02[-\/.](\d{2}(0[48]|[2468][048]|[13579][26])|([02468][048]|[1359][26])00))[\w -]*[-]*[\w -](((0[13578]|1[02])|(0[1-9]|[12][0-9]|30)[-\/.](0[469]|11)|(0[1-9]|1\d|2[0-8])[-\/.]02)[-\/.](0[1-9]|[12][0-9]|3[01])[-\/.]\d{4}|29[-\/.]02[-\/.](\d{2}(0[48]|[2468][048]|[13579][26])|([02468][048]|[1359][26])00))[)]/'; } elseif (in_array($dateFormat->value, [ 'YYYY/MM/DD', 'YYYY-MM-DD' ])) { $regex = '/[" "][(](\d{4}|29[-\/.]02[-\/.](\d{2}(0[48]|[2468][048]|[13579][26])|([02468][048]|[1359][26])00))[-\/.]((0[13578]|1[02])|(0[1-9]|[12][0-9]|30)[-\/.](0[469]|11)|(0[1-9]|1\d|2[0-8])[-\/.]02)[-\/.](0[1-9]|[12][0-9]|3[01])[\w -]*[-]*[\w -](\d{4}|29[-\/.]02[-\/.](\d{2}(0[48]|[2468][048]|[13579][26])|([02468][048]|[1359][26])00))[-\/.]((0[13578]|1[02])|(0[1-9]|[12][0-9]|30)[-\/.](0[469]|11)|(0[1-9]|1\d|2[0-8])[-\/.]02)[-\/.](0[1-9]|[12][0-9]|3[01])[)]/'; } foreach ($items AS $v) { $v->description = preg_replace($regex, '', $v->description); Capsule::table('tblinvoiceitems')->where('id', '=', $v->id)->update([ 'description' => $v->description ]); } }); 0 Quote Link to comment Share on other sites More sharing options...
cluster Posted 8 hours ago Author Share Posted 8 hours ago If I extend the condition w/ "type" -> DomainRegister ... that should work, but it doesn't ... (no preg_replace). e.g. $ptype = "DomainRegister"; $items = Capsule::table('tblinvoiceitems')->select('id', 'type', 'description')->where('type', $ptype)->where('invoiceid', '=', $vars['invoiceid'])->get(); or $ptype = "DomainRegister"; $items = Capsule::table('tblinvoiceitems')->select('id', 'type', 'description')->where('type', '=', $ptype)->where('invoiceid', '=', $vars['invoiceid'])->get(); did I missed something here... what am I doing wrong? 0 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.