Building a Home Page widget

Adding information to the admin dashboard

Creating a widget of your own is just a matter of modifying admin/index_dashboard.php and adding in your logic. For example, one store wanted to monitor orders in a specific status, and make them visible on the home page. Here’s what they did:

    <div class="reportBox">
        <div class="header"><?php echo "Held Orders"; ?> </div>
        <?php  $orders = $db->Execute("SELECT o.orders_id AS orders_id, o.customers_name AS customers_name, o.date_purchased AS date_purchased, ot.text AS order_total FROM " . TABLE_ORDERS . " o LEFT JOIN " . TABLE_ORDERS_TOTAL . " ot ON (o.orders_id = ot.orders_id and class = 'ot_total') WHERE orders_status = 7 ORDER BY orders_id DESC");

        if ($orders->EOF) {
          echo '              <div class="row">No Held Orders</div>' . "\n"; 
        } else { 
          while (!$orders->EOF) {
            echo '              <div class="row"><span class="left"><a href="' . zen_href_link(FILENAME_ORDERS, 'oID=' . $orders->fields['orders_id'] . '&action=edit&origin=' . FILENAME_DEFAULT, 'NONSSL') . '" class="contentlink"> ' . $orders->fields['customers_name'] . '</a></span><span class="center">' . $orders->fields['order_total'] . '</span><span class="right">' . "\n";
            echo zen_date_short($orders->fields['date_purchased']);
            echo '              </span></div>' . "\n";
            $orders->MoveNext();
          }
        }
        ?>
    </div>

A plugin called Orders in Status Dashboard Widget can be used to build something similar for your site.




Still have questions? No problem! Just head over to the Zen Cart support forum and ask there in the appropriate subforum. In your post, please include your Zen Cart and PHP versions, and a link to your site.

Is there an error or omission on this page? Please post to General Questions on the support forum. Or, if you'd like to open a pull request, just review the guidelines and get started. You can even PR right here.
Last modified September 13, 2020 by Scott C Wilson (354bf51).