Jump to content

Auto set product status to Completed?


robetus

Recommended Posts

Is there currently a way with WHCMS 7.3 to automatically set a certain product to Completed instead of Active when the invoice is paid or the product/service has been delivered? I was thinking about a simple if statement somewhere, if product name is this then status = completed. Any ideas on how I could do this?

Link to comment
Share on other sites

if you want to automate it, then you will need a hook - i'd suggest using product IDs rather than names, because you could make two products have the same name, but they'd still have different product IDs... it's basically just going to be a table update.

also, you'd have to ensure that you were only doing this on non-recurring (e.g one-time) products..

https://docs.whmcs.com/Products_Management

Quote

Note: The status of the service, domain or addon must be Pending, Active or Suspended to generate an invoice.

 

Link to comment
Share on other sites

  • 2 months later...
On 10/9/2017 at 11:42 AM, robetus said:

Okay thanks, I'll get someone to work on the hook.

Just wondering if you ever got this created? We're looking to create something similar but if you've already made the hook we'd be happy to purchase from you rather than making it ourselves?

Link to comment
Share on other sites

Yes I did, figured it out myself and here it is:

<?php

use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Database\Schema\Blueprint;

if (!defined("WHMCS")) {
    die("This file cannot be accessed directly");
}


function modname_CreateAccount($params)
{
     Capsule::table('tblhosting')
        ->where('id', $params['serviceid'])
        ->update(
          [
                'domainstatus' => 'Completed',
          ]
       );
}

This simple function will change the product status to Completed. You just need to make a server module with this php code inside the file, change modname to what you want to name the module and name the php file the same name. Or you can use it inside a pre-existing module you've already created.  WHMCS should really do this as an option. Enjoy!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • 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