Jump to content

Don't auto provision when there's a note


YeapGuy

Recommended Posts

  • 2 weeks later...
11 minutes ago, Kian said:

In PreModuleCreate hook point run a query to detect if there's a note. If the note can't be found, send abortcmd => true to stop the provisioning.

p.s. There are better ways to prevent bots from placing orders

Thanks, could you provide me with more exact instructions? I'm new to this haha.
And it's not for bots, I just want to leave the order for manual review if the customer wants something custom/special.

Link to comment
Share on other sites

Begin by creating a file named as you prefer (eg. AbortCreate.php) in includes/hooks directory. The content of this file should be the following:

<?php

use WHMCS\Database\Capsule;

add_hook('PreModuleCreate', 1, function($vars)
{
    $Data = Capsule::select(Capsule::raw('SELECT t1.notes FROM tblorders AS t1 LEFT JOIN tblhosting AS t2 ON t1.id = t2.orderid WHERE t2.id = "' . $vars['params']['serviceid'] . '" AND t2.orderid != "0"'));

    if ($Data[0]->notes)
    {
        return array('abortcmd' => true);
    }
});

Everytime Create function triggers, this hook looks for notes in the order. If the order has a note, it returns abortcmd true. This will stop the auto-provisioning of WHMCS. Keep in mind that you need further changes to my basic example. In fact unless at some point you remove the notes from the order, the script will keep aborting the provisioning.

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