Totally Zenned
- Join Date:
- Jun 2005
- Location:
- Kelowna, BC Canada
- Posts:
- 1,033
- Plugin Contributions:
- 4
stockFilter for 1.3.5
stockFilter is a new contribution I came up with today.
It is mostly useful for stores that have a significant amount of special order items available to your customers (ie. products that are not in stock) but you also have in-stock items. Feedback from my customers has been that some of them would like to know ONLY what is in stock.
From the readme:```
Contribution: Stock Filter
Release: 1.00
Author: s_mack
Compatibility: Tested with ZenCart v. 1.3.5
Purpose:
To allow a user to limit the products shown to only what is currently in stock if they so choose, by way of a sidebox. By default, they see all items they normally would see (depends on how you set up your admin).
Optionally: To visually inform and remind the user that the filter has been applied or cleared through use of the ZenCart MessageStack feature.
File List:
./changelog.txt
./ReadMe.txt
./includes/auto_loaders/config.stockFilter.php
./includes/classes/message_stack.php
./includes/init_includes/init_stockFilter.php
./includes/languages/english/extra_definitions/YOUR_TEMPLATE/stock_filter_definitions.php
./includes/modules/YOUR_TEMPLATE/product_listing.php
./includes/modules/sideboxes/YOUR_TEMPLATE/stock_filter.php
./includes/templates/YOUR_TEMPLATE/sideboxes/tpl_stock_filter.php
Installation - Basic:
- Change all instances of the folder name "YOUR_TEMPLATE" to your template's name (see file list above)
- Take caution with the product_listing.php file. Even though this is not a core file, it may already exist and have been modified by a different contrib. If you already have this file, then carefully merge the changes using a program such as WinMerge (hint: it is only 1 line near the top of the file)
- Copy all files in the /includes folder EXCEPT for classes/message_stack.php to your shop, retaining folder structure. No core files are touched at this point.
- In your site admin, go to Tools -> Layout Boxes Controller and turn on your new stock_filter sidebox.
Installation - Advanced/Optional
In order to use the optional MessageStack features of this contribution, the following steps must be performed:
- Merge or copy the classes/message_stack.php to your store. Take caution that this is a core file! It is preferable that you merge the files using a tool like WinMerge, just in case the core file has changed since this release.
- Uncomment line 11 in the init_stockFilter.php file
- If you want the user to have a continued reminder that the filter is applied, create an appropriate css definition(s) for .messageStackLightCaution. Use the pre-existing .messageStackCaution as a model, and change the colors to suit (typically you would want a lighter background and lighter text for a more subdued effect).
- If you do not want the continued reminder, then In the stock_filter_definitions.php file, change line 13 to:
define('TEXT_MESSAGESTACK_FILTER_REMINDER', ''); - Edit the stock_filter_definitions.php file, and copy to other languages as required.
Un-Installation:
- Delete all the files from this package (see list above) from your store. Reverse any modifications to core and/or existing files that you performed during install (or simply revert to a backup).
Notes:
- ALWAYS back up all files before overwriting.
- The sidebox (and optionally the MessageStack) will not be visible, and filters not applied, on certain key pages as defined near the top of the init_stockFilter.php file. This is important, for example, because a customer may add an item to their cart THEN apply the filter and subsequently checkout. If the filter were still applied, this could be confusing for the user, and possibly disastrous for the database (I'm not sure what would be the consequence). You should certainly leave the defined page exclusions in that aforementioned file, but you may need to add more as well, depending on preference as well as other contributions you may have installed. Essentially, you should look for pages where it could be problematic if the filter were hiding items and add them to the defines.
- It is certainly conceivable that this system could be adapted for other filtering goals. However, filtering by stock is quite simple while other filters could be extremely complex and require changing many core files - so proceed with caution. Please credit me (s_mack) in your release if this contrib inspires another.
I'll post a link when the contribution submission has been approved (up to 48 hours)
- Steven