JuniYadi Posted March 28, 2020 Share Posted March 28, 2020 Hi, i'm just implementation fraud protection, and check on order setup for : Tick this box to skip the fraud check for existing clients who already have an active order i want to make widget in client area showing if user already have an active order, then it's show: you can order without fraud check. any suggest query sql or how to do this? Thanks 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted March 28, 2020 Share Posted March 28, 2020 8 hours ago, JuniYadi said: i want to make widget in client area showing if user already have an active order, then it's show: you can order without fraud check. if we keep it simple and make it a bootstrap alert for now, then the hook code would be a variation of the one I posted in the thread below... 8 hours ago, JuniYadi said: any suggest query sql or how to do this? you wouldn't particularly need a SQL query for this... <?php add_hook('ClientAreaHomepage', 1, function($vars) { $client = Menu::context('client'); $activeorders = $client->orders->where('status','Active')->count(); if ($client && $activeorders > 0) { return '<div class="text-center"><div class="alert alert-success" role="alert">You can order without fraud check - click <a href="cart.php">here</a>.</div></div><br />'; } }); so if the user has active orders, then an alert is shown on the homepage... if the user has no active orders, then the message alert isn't shown. ... and if you still want to make it into a homepage panel (widget), then the first three lines inside the hook code would be the same, you would just need to follow the panel examples in the docs... 1 Quote Link to comment Share on other sites More sharing options...
JuniYadi Posted March 29, 2020 Author Share Posted March 29, 2020 Thank @brian! Solved now, if someone need widget. and here the hooks. <?php use WHMCS\View\Menu\Item; add_hook('ClientAreaHomepagePanels', 1, function (Item $homePagePanels) { $client = Menu::context('client'); $activeorders = $client->orders->where('status','Active')->count(); if ($client && $activeorders > 0) { $fraudPanel = $homePagePanels->addChild('account status', array( 'label' => 'Account Status', 'icon' => 'fas fa-user-shield', 'extras' => array( 'color' => 'blue', ), 'bodyHtml' => "<p>Account Status: <strong>Premium Account</strong></p>", )); } // Showing to First Panel $fraudPanel->moveToFront(); }); 0 Quote Link to comment Share on other sites More sharing options...
AdamGunderson Posted August 1, 2023 Share Posted August 1, 2023 When I use the following code, it throws an error anytime a user is not logged in. Any ideas why? add_hook('ClientAreaSidebars', 1, function() { $client = Menu::context('client'); $activeorders = $client->orders->where('status','Active')->count(); if ($client && $activeorders > 0) { GLOBAL $smarty; $templatefile = $smarty->getVariable('templatefile'); $allowedpages = ['clientareahome','homepage','knowledgebase']; if (in_array($templatefile, $allowedpages)) { $client = Menu::context('client'); $secondarySidebar = Menu::secondarySidebar(); $title = 'Write Us A Review'; $bodyHtml = '<!-- CUSTOM HTML HERE -->'; $secondarySidebar->addChild('Review') ->setLabel($title) ->setBodyHtml($bodyHtml) ->setIcon('fa-star') ->setOrder(100); } } }); 0 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.