Totally Zenned
- Join Date:
- Aug 2004
- Posts:
- 732
- Plugin Contributions:
- 0
[FEATURE] Who's Online - Show only "Cart Has Items" filter
NEW FEATURE - Filter your Who's Online list to show only Carts With Items (active and inactive), and hide all the rest.
This is something I have always wanted and added this quick workaround on my own site.
Sometimes, you want to see who is active and what items are in their carts. You may not care to see all the sessions where people aren't shopping.
Currently, the WHOS_ONLINE.php only filters between Spiders and Admin sessions. When a site like mine has hundreds or even thousands of sessions, it's frustrating to scroll the page looking for the green or yellow "active cart" circles just to see what items are being actively shopped.
I wanted the WHOS ONLINE to only list the cart sessions that had items inside of them, and hide the rest.
So I added the following code to give that extra toggle to display only Cart Has Items sessions.
Current Version - Zen Cart 2.2
On line 9:
define('TEXT_WHOS_ONLINE_FILTER_CART_NOT_EMPTY', 'Cart Has Items:');
On line 38:
if (!isset($_SESSION['wo_cart_not_empty_only'])) {
$_SESSION['wo_cart_not_empty_only'] = false;
}
if (isset($_GET['ac'])) {
$_SESSION['wo_cart_not_empty_only'] = $_GET['ac'] != 0;
}
On line 62:
if (!empty($_SESSION['wo_cart_not_empty_only'])) {
$whos_online = array_filter($whos_online, function ($item) {
return substr($item['icon_class'], -10) === '-not-empty';
});
}
On line 72:
$optURL = zen_href_link(FILENAME_WHOS_ONLINE, zen_get_all_get_params(['t', 'na', 'ns', 'ac'])) . '&'; // added 'ac'
$listingURL = zen_href_link(FILENAME_WHOS_ONLINE, zen_get_all_get_params(['q', 't', 'na', 'ns', 'ac'])) . '&'; // added 'ac'
On line 136:
<?php echo TEXT_WHOS_ONLINE_FILTER_CART_NOT_EMPTY; ?>
<a class="optionClick<?php echo ($_SESSION['wo_cart_not_empty_only']) ? ' chosen' : ''; ?>" href="<?php echo $optURL; ?>ac=1"><?php echo TEXT_YES; ?></a>
<a class="optionClick<?php echo (!$_SESSION['wo_cart_not_empty_only']) ? ' chosen' : ''; ?>" href="<?php echo $optURL; ?>ac=0"><?php echo TEXT_NO; ?></a>
- Jeff