Nikil Posted August 10, 2020 Share Posted August 10, 2020 Hi there, I am pretty new to WHMCS. I wonder if someone could help with there thought. I will be grateful. It is related to order status. i have created new status WIP (work in progress) from admin side. Is there any possible way to make that status update once the order's payment completed.I like automate the WIP status update once payment completed. Is there any hook which could help me with this? or any other possible work around? Thanks in Advance. 0 Quote Link to comment Share on other sites More sharing options...
Nikil Posted August 10, 2020 Author Share Posted August 10, 2020 https://whmcs.community/topic/285777-a-hook-that-runs-just-before-the-payment-is-done-or-just-before-an-invoice-is-paid/?do=findComment&comment=1289021 @brian! Can i meet my requirement with this following hook ? I see only invoiceid param available. But i need to update order status once payment completed. Can you please share your thoughts? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 12, 2020 Share Posted August 12, 2020 Hi @Nikil On 10/08/2020 at 16:26, Nikil said: Can i meet my requirement with this following hook ? I see only invoiceid param available. But i need to update order status once payment completed. it would work - although i'd be inclined to use InvoicePaid as it doesn't really matter whether the order status is changed before or after the email is sent to the client because client's can't see order statuses (it is the order status you want to change and not the product status) ? the fact that you have the invoiceid value is fine - you can look for that value in the tblorders database table, and just run a simple update query to change the status to WIP. 1 Quote Link to comment Share on other sites More sharing options...
Nikil Posted August 19, 2020 Author Share Posted August 19, 2020 Hi @brian! Thanks for that explanation. After trying those out i am came to an understanding. I need to change product(domain) status into WIP once payment ccompleted. I tried with same hook InvoicePaid using it's invoiceid i got the orderid from tblorders. With that orderid i loaded tbldomains and updated status. But custom status not updating for products. I like to show that "WIP" status in Front-end My Domains and Domains detail page for payment completed Products(domains). Could you please let me know how to meet my requirements? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 19, 2020 Share Posted August 19, 2020 Hi @Nikil 30 minutes ago, Nikil said: I need to change product(domain) status into WIP once payment completed. the problem here is that you can't have custom product or domain statuses in WHMCS. https://requests.whmcs.com/topic/custom-service-status https://requests.whmcs.com/topic/option-to-display-custom-statuses-to-the-client now I suppose you could run a database query to update the values, but I doubt that's recommended. 58 minutes ago, Nikil said: I like to show that "WIP" status in Front-end My Domains and Domains detail page for payment completed Products(domains). why Domains? if it's a product in the order, it's going to be My Products and products details... i'd certainly be leaving domain statuses alone in the database as WHMCS needs to know internally what they are. you always have the option of renaming the label of an existing status - i'm thinking in terms of products, but I might work in domains.... e.g if we rename Pending to WIP... ... there's no coding to do that, just Language Overrides.... and then when you want to change a product status to WIP, just change it to Pending. 1 Quote Link to comment Share on other sites More sharing options...
Nikil Posted September 3, 2020 Author Share Posted September 3, 2020 (edited) Hi @brian! Thanks for all those suggestion. In our scenario we need both Pending and WIP. So, We updated the order status using InvoicePaid hook. using that order's status we changed ClientAreaPageDomains and ClientAreaPageDomainDetails output variables add_hook('ClientAreaPageDomains', 1, function($vars) { $newClient = $vars['client']; $orderIds = []; $domainsCollection = $newClient->domains; foreach ($domainsCollection as $domain) { $orderIds[$domain->id] = $domain->orderid; } if (!(count($orderIds) > 0)) { return $vars; } foreach ($vars['domains'] as $key => $domain) { $orderid = $orderIds[$domain['id']]; $orderStatus = Capsule::table('tblorders')->where('id',$orderid)->value('status'); if ($orderStatus == 'WIP') { $domain['status'] = $orderStatus; $domain['statusClass'] = $orderStatus; $domain['rawstatus'] = $orderStatus; $domain['statustext'] = $orderStatus; } $vars['domains'][$key] = $domain; } return $vars; }); It may be a dirty way but works fine for our requirement. Edited September 3, 2020 by Nikil 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 3, 2020 Share Posted September 3, 2020 4 hours ago, Nikil said: In our scenario we need both Pending and WIP. aah.. always the way! 🙂 4 hours ago, Nikil said: using that order's status we changed ClientAreaPageDomains and ClientAreaPageDomainDetails output variables I suspect you could trim that right down along the lines of.... add_hook('ClientAreaPageDomains', 1, function($vars) { $domains = $vars['domains']; foreach ($domains as $key => $domain) { $orderid = Capsule::table('tbldomains')->where('id',$domain['id'])->value('orderid'); if ($orderid != '0') { $orderStatus = Capsule::table('tblorders')->where('id',(int)$orderid)->value('status'); if ($orderStatus == 'WIP') { $domains[$key]['status'] = $domains[$key]['statusClass'] = $domains[$key]['rawstatus'] = $domains[$key]['statustext'] = $orderStatus; } } } return array("domains" => $domains); }); i'm cheating a little with the status declarations because under normal circumstances, all four variables shouldn't use the same exact value - two will be lowercase, the other two will be capitalised - though because its WIP, and you might not be specifying a CSS class, you can probably get away with this. although i'm still not sure that I follow why you're changing/masking the status of the domain rather than the product's domainstatus value - which are two separate values in the database. 1 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.