zarvis Posted July 19, 2019 Share Posted July 19, 2019 Hello, I am trying to make a widget and in that I am using Internal API to fetch the product wth status suspended and due date greater than today. <?php use WHMCS\Database\Capsule; add_hook('AdminHomeWidgets', 1, function() { return new HelloWorldWidget(); }); /** * Hello World Widget. */ class HelloWorldWidget extends \WHMCS\Module\AbstractWidget { protected $title = 'Hello World'; protected $description = ''; protected $weight = 150; protected $columns = 1; protected $cache = false; protected $cacheExpiry = 120; protected $requiredPermission = ''; public function getData() { $command = 'GetClientsProducts'; $postData = array( 'status' => 'Suspended', //nextsuedate should be greater than today ); $products = localAPI($command, $postData); //$products = localAPI('GetClientsProducts', []); return array( 'welcome' => 'Hello World!', 'products' => $products['products'], ); } public function generateOutput($data) { $clientOutput = []; foreach ($data['products']['product'] as $product) { $clientOutput[] = "<a href=\"clientsservices.php?id={$product['id']}\">{$product['id']}</a>"; } if (count($clientOutput) == 0) { $clientOutput[] = 'No Clients Found'; } $clientOutput = implode('<br>', $clientOutput); return <<<EOF <div class="widget-content-padded"> <div>{$data['welcome']}</div> <div id="sampleWidgetClientOutput">{$clientOutput}</div> </div> EOF; } } I tried with just status as suspended but it is returning all the orders. 0 Quote Link to comment Share on other sites More sharing options...
wsa Posted July 23, 2019 Share Posted July 23, 2019 Hello, Please contact us for any WHMCS development here Hope to hear from your 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 23, 2019 Share Posted July 23, 2019 On 19/07/2019 at 09:05, zarvis said: I tried with just status as suspended but it is returning all the orders. as I think it's supposed to. just add an if statement to the $clientoutput loop and your array should only contain suspended services.... $clientOutput = []; foreach ($data['products']['product'] as $product) { if ($product['status'] == 'Suspended') { $clientOutput[] = "<a href=\"clientsservices.php?id={$product['id']}\">{$product['id']}</a>"; } } 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.