Jump to content

Order Status


Nikil

Recommended Posts

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.

Link to comment
Share on other sites

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?

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

 

Link to comment
Share on other sites

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.

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...

GqffCNw.pngzRdzvG8.png

... 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.

Link to comment
Share on other sites

  • 2 weeks later...

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 by Nikil
Link to comment
Share on other sites

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.

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • 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