Claudia M Posted Saturday at 05:16 PM Share Posted Saturday at 05:16 PM I am trying to add a sortable checkbox for latest products on the product inventory page in admin. I change my latest products frequently and want to keep track of them. I can get the checkbox to show up, I just can't get it to work. I've added this so the checkbox doesn't take up a lot of room on the product inventory page <thead> <tr> <th nowrap="nowrap"> </th> <th nowrap="nowrap">{$THEAD.name}</th> <th nowrap="nowrap">LP</th> <th nowrap="nowrap">{$THEAD.image}</th> A few lines later I put this <span class="light-category">{$product.category}</span> {/if} </td> <td style="text-align:center"><input type="hidden" name="latest" id="product_latest" class="toggle" value="{$PRODUCT.latest}"></td> <td style="text-align:center"> {if !empty($product.image_path_tiny)} I know I need to put something like this in the source file to make it sortable but I need to get it to work first // Sorting $current_page = currentPage(array('sort')); if (!isset($_GET['sort']) || !is_array($_GET['sort'])) { $_GET['sort'] = array('updated' => 'DESC'); } $thead_sort = array( 'status' => $GLOBALS['db']->column_sort('status', $lang['common']['status'], 'sort', $current_page, $_GET['sort']), 'digital' => $GLOBALS['db']->column_sort('digital', $lang['common']['type'], 'sort', $current_page, $_GET['sort']), 'product_latest' => $GLOBALS['db']->column_sort('product_latest', $lang['catalogue']['type'], 'sort', $current_page, $_GET['sort']), The checkbox won't stay checked and I didn't want to go any further and mess everything up. Thanks for any and all help Claudia Quote Link to comment Share on other sites More sharing options...
bsmither Posted Saturday at 08:30 PM Share Posted Saturday at 08:30 PM In the $thead_sort array of the admin script, please try: 'product_latest' => $GLOBALS['db']->column_sort('latest', 'LP', 'sort', $current_page, $_GET['sort']), Then, in the <thead> block of the admin skin template, use: <th nowrap="nowrap">{$THEAD.product_latest}</th> In the corresponding slot in the group of <td> cells, use: <td align="center"><input type="hidden" name="latest[{$product.product_id}]" id="latest_{$product.product_id}" value="{$product.latest}" class="toggle"></td> Then, finally, back in the script, to process the checkboxes for being in the Latest Products group: Find: if (isset($_POST['status']) && is_array($_POST['status']) && Admin::getInstance()->permissions('products', CC_PERM_EDIT)) { // Update Status foreach ($_POST['status'] as $product_id => $status) { $GLOBALS['db']->update('CubeCart_inventory', array('status' => $status), array('product_id' => $product_id)); } Add after: if (isset($_POST['latest']) && is_array($_POST['latest']) && Admin::getInstance()->permissions('products', CC_PERM_EDIT)) { // Update Latest Product state foreach ($_POST['latest'] as $product_id => $state) { $GLOBALS['db']->update('CubeCart_inventory', array('latest' => $state), array('product_id' => $product_id)); } } Quote Link to comment Share on other sites More sharing options...
Claudia M Posted Saturday at 09:10 PM Author Share Posted Saturday at 09:10 PM Thank you Brian .... that did it! This should maybe be something that is stock in Cubecart? A lot of people don't really use this for the most current products Quote Link to comment Share on other sites More sharing options...
havenswift-hosting Posted Saturday at 09:55 PM Share Posted Saturday at 09:55 PM Hi Claudia You should be using our Enhanced Sorting plugin which adds this and a load of other sorting with no core file changes Ian Quote Link to comment Share on other sites More sharing options...
Claudia M Posted Saturday at 10:25 PM Author Share Posted Saturday at 10:25 PM Hi Ian, I looked at that and though it is a great plugin I think I have things the way I want now. I did purchase the Automatic XML Sitemap Generator from you for my new site but it's showing pending. Is there something I need to do? Claudia 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.