Jump to content

Problem with the script and the database


Recommended Posts

Hello I am writing with a problem related to creating a custom hook. I have already written all the ready code but unfortunately not everything works in it as it should. Below I send the code and the error. In the screenshot I send what logModuleCall returns.

use WHMCS\Database\Capsule;
add_hook('AfterShoppingCartCheckout'1function($vars) {
    $orders = Capsule::table('tblorders')
    logModuleCall('BetterAffilance''Sended data'json_encode($orders), json_encode($vars));
    $partners = [
        'minerpl' => 2,
    if($partners[$orders->promocode]) {
        logModuleCall('BetterAffilance''User use partner code!'$partners[$orders->promocode], $vars['ServiceIDs'][0]);
        try {
                function ($connectionManager)
                    /** @var \Illuminate\Database\Connection $connectionManager */
                            'affiliateid' => $partners[$orders->promocode],
                            'relid' => $vars['ServiceIDs'][0],
        } catch (\Exception $e) {
            logModuleCall('BetterAffilance''Error when inserting data to database'$e->getMessage(), $e->getMessage());


SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'affiliateid' cannot be null (SQL: insert into `tblaffiliatesaccounts` (`affiliateid`, `relid`) values (?, ?))


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.

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