bsmither Posted April 26, 2019 Share Posted April 26, 2019 Please make this edit. In /classes/catalogue.class.php: Lines 1835-1849: From: if (isset($search_data['featured'])) { $where[] = "I.featured = '1'"; } // Only look for items that are in stock if (isset($search_data['inStock'])) { $where[] = $this->outOfStockWhere(); } $whereString = (isset($where) && is_array($where)) ? implode(' AND ', $where) : ''; if (!empty($whereString)) { $whereString = ' AND '.$whereString; } $whereString .= $this->_where_live_from; $joinString = (isset($joins) && is_array($joins)) ? implode(' JOIN ', $joins) : ''; To: if (isset($search_data['featured'])) { $where[] = "I.featured = '1'"; } $whereString = (isset($where) && is_array($where)) ? implode(' AND ', $where) : ''; // Only look for items that are in stock if (true || isset($search_data['inStock'])) { // Forcing a filter for only in-stock items. Includes _where_live_from. $whereString .= $this->outOfStockWhere(false,'I'); // BUG!! Using this method at this location requires using the table alias. } else { $whereString .= $this->_where_live_from; // Adding the _where_live_from to the $whereString. } if (!empty($whereString)) { $whereString = ' AND '.$whereString; $whereString = str_replace('AND AND', 'AND', $whereString); // Hack to kill double verb from empty $where[] causing _where_live_from being first. Note two spaces between verbs. } $joinString = (isset($joins) && is_array($joins)) ? implode(' JOIN ', $joins) : ''; Link to comment Share on other sites More sharing options...
warpsor Posted April 26, 2019 Share Posted April 26, 2019 looks as though there are some missing braces. Please confirm... if (isset($search_data['featured'])) { //<- here ... } else { $whereString .= $this->_where_live_from; // Adding the _where_live_from to the $whereString. } //<- and here With these changes, It appeaars to be working. NOTE to anyone else... copying and pasting this code made the double space between ANDs go away. Link to comment Share on other sites More sharing options...
bsmither Posted April 26, 2019 Share Posted April 26, 2019 Thanks for catching that. Fixed. (I added diagnostic code which, if the reporting function is missing, will cause a fatal error. In deleting that code prior to posting, I sometimes delete too much. I really must double check that.) Link to comment Share on other sites More sharing options...
gjkathome Posted June 24, 2020 Share Posted June 24, 2020 On 7/31/2017 at 7:57 PM, Robando said: Hi all, I have a few out of stock products on my store that I do not want to be displayed. I have gone to settings > store settings > stock and checked Hide out-of-stock product but the items are still displayed. Am I right in thinking this setting should hide out of stock products? I've found a solution I cleared my browsers cache and the out of stock items are no longer displayed I am back on the original problem in this thread. I have a product with 10 options. There is exactly one item in stock for each option. When I buy an item the stock level shows as zero in the options matrix but the option still shows up in the option selection box when making a guest purchase. I am using Cubecart 6.2.8 I have "Hide out-of-stock" checked in Store Settings -> Stock Also have "Main stock level as matrix stock level summary" checked Stock level is correct in "Products -> [Product Name] -> General "Use Stock Level" is checked in "Products -> [Product Name] -> General I have cleared the Cubecart cache I have cleared the browser's cache. There must be something I have missed? Any suggestions gratefully received. Graham Link to comment Share on other sites More sharing options...
bsmither Posted June 24, 2020 Share Posted June 24, 2020 There is a plugin that will enhance CubeCart's displaying of the products' options (when using the Options Matrix table). The normal behavior of CubeCart is to show all options all the time. This is because when creating a matrix of options, that matrix could grow exponentially. Thus with only a few option types with a few values per type, for example four option types with four values per, the total matrix is 4^4=256 different combinations. Code would need to be developed to scale from very simple to the very ridiculous. As such, CubeCart won't even try. When attempting to add to cart, CubeCart will ten come back and say, "Sorry, that combo is out of stock." Personally, I've given thought to how best to show up to twelve option types with several values per type. I'm sure Google Charts has a solution. The plugin (I believe) simply lists all the combinations found in the Options Matrix table with but with zero stock level combos removed. Link to comment Share on other sites More sharing options...
gjkathome Posted June 25, 2020 Share Posted June 25, 2020 Just to be sure I have understood. With vanilla CubeCart, even with just one option group, all options in the group are shown in the drop-down list including those that are out of stock. Selecting an out-of stock item results in an error message. I don't understand your reference to "the plugin" and Google Charts. Is there a plugin I can use to solve my problem? Thanks for your help. Graham Link to comment Share on other sites More sharing options...
bsmither Posted June 25, 2020 Share Posted June 25, 2020 The plugin I was referring to is: https://www.cubecart.com/extensions/plugins/absolute-matrix-option-prices-price-list-hide-out-of-stock-matrix-options I was making a remark about Google Charts as that system seems to have a very wide variety of display types for various datasets, and that there is probably a chart type that resembles what I had envisioned a few years back. I'm not saying there is such a chart, but only that there probably is. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.