zitu4life Posted December 3 Share Posted December 3 Hello, I have searched on the community and did not find yet a solution, also have tried my self and not successfully. I want to invoice in a daily basis a custon product, and realizing that billable items do that, which is great! But the issue is that I want to add automatic date on each of these new invoice that will be created by billable itens. have tried so far this.. but using {DAY}-{MONTH}-{YEAR} on the description will not display it as 03-12-2025 I suspect WHMCS accepts HTML code or smarty code templates that will do that, but can no do it at this. If anyone can advice or help. I got this, bu I need it to display actually date the invoice was generated, so evey new invoice to display actual date on the desciption. This is what I look for... Thank you!!! 0 Quote Link to comment Share on other sites More sharing options...
Solution towhiddex Posted December 3 Solution Share Posted December 3 Hello, It's very easy to resolve with Hook, just do Create a hook file at: whmcs/includes/hooks/invoice-lineitem-date.php <?php use Illuminate\Database\Capsule\Manager as Capsule; use Carbon\Carbon; add_hook('InvoiceCreationPreEmail', 1, function ($vars) { $invoiceId = (int) $vars['invoiceid']; $inv = Capsule::table('tblinvoices')->where('id', $invoiceId)->first(); if (!$inv) { return; } $dateText = Carbon::parse($inv->date)->format('d-m-Y'); $items = Capsule::table('tblinvoiceitems') ->where('invoiceid', $invoiceId) ->get(); foreach ($items as $item) { $isBillableItem = ($item->type === 'Item'); if (!$isBillableItem) { continue; } $newDescription = $item->description; if (strpos($newDescription, '{DAY}') !== false || strpos($newDescription, '{MONTH}') !== false || strpos($newDescription, '{YEAR}') !== false) { $newDescription = preg_replace( '/\{DAY\}\s*-\s*\{MONTH\}\s*-\s*\{YEAR\}/i', $dateText, $newDescription ); } else { $newDescription .= " ({$dateText})"; } Capsule::table('tblinvoiceitems') ->where('id', $item->id) ->update(['description' => $newDescription]); } }); 1 Quote Link to comment Share on other sites More sharing options...
zitu4life Posted December 4 Author Share Posted December 4 Hi @towhiddex Thank you for taking your time with me. I have aplied this hook, I tried to create imediately new billable item on next cron, but no invoice was generated, not sure why yet..but let me test it more and will post here. 0 Quote Link to comment Share on other sites More sharing options...
zitu4life Posted December 5 Author Share Posted December 5 a quick update @towhiddex many many thanks, it works!!!!!!!!!!!! 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.