Forums / All Other Contributions/Addons / stockFilter for 1.3.5

stockFilter for 1.3.5

Views: 6,429

Results 1 to 20 of 43
12 Sep 2006, 8:47 PM
#1
s_mack avatar

s_mack

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:

  1. ALWAYS back up all files before overwriting.
  2. 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.
  3. 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
13 Sep 2006, 2:55 AM
#2
s_mack avatar

s_mack

Totally Zenned

Join Date:
Jun 2005
Location:
Kelowna, BC Canada
Posts:
1,033
Plugin Contributions:
4

Re: stockFilter for 1.3.5

link

  • Steven
20 Sep 2006, 6:29 PM
#3
s_mack avatar

s_mack

Totally Zenned

Join Date:
Jun 2005
Location:
Kelowna, BC Canada
Posts:
1,033
Plugin Contributions:
4

Re: stockFilter for 1.3.5

I've now updated this contrib to include all (core) sideboxes and modules that display products, with the exception of the "upcoming products" module (because by definition those items aren't in stock).

From the readme:

Contribution: Stock Filter
Release: 2.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). Previous version was limited to product listings only. Starting with v.2, this filtering now extends to modules (whats_new, specials, featured, bestsellers, etc) as well as the main categories display (both sidebox and index).  For example, if you have a category that contains only products that are not in stock, that category will not be displayed if the customer chooses to turn the filter on.

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  ***CORE FILE***
./includes/functions/extra_functions/functions_stockFilter.php
./includes/init_includes/init_stockFilter.php
./includes/languages/english/extra_definitions/YOUR_TEMPLATE/stock_filter_definitions.php
./includes/modules/sideboxes/YOUR_TEMPLATE/best_sellers.php
./includes/modules/sideboxes/YOUR_TEMPLATE/featured.php
./includes/modules/sideboxes/YOUR_TEMPLATE/reviews.php
./includes/modules/sideboxes/YOUR_TEMPLATE/specials.php
./includes/modules/sideboxes/YOUR_TEMPLATE/stock_filter.php
./includes/modules/sideboxes/YOUR_TEMPLATE/whats_new.php
./includes/modules/YOUR_TEMPLATE/also_purchased_products.php
./includes/modules/YOUR_TEMPLATE/featured_products.php
./includes/modules/YOUR_TEMPLATE/new_products.php
./includes/modules/YOUR_TEMPLATE/product_listing.php
./includes/modules/YOUR_TEMPLATE/category_row.php
./includes/modules/YOUR_TEMPLATE/specials_index.php
./includes/templates/YOUR_TEMPLATE/sideboxes/tpl_categories.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 any file that may be over-written! Even though these are not a core file, they may already exist and have been modified by a different contrib. If you already have any of these files, then carefully merge the changes using a program such as WinMerge.
 - 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.
 - Lines 29 thru 31 in the init_stockFilter.php file contain some configurable options... read the comments at the endof each line for tips.

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:
1) ALWAYS back up all files before overwriting.
2) 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.
3) Since version 2, the filtering has moved beyond the main product listings, and into all core sideboxes and index modules. For example, if the user turns filtering on, then the BestSeller list will only show items that are in-stock. If you have contributions installed that display products and you want them filtered, then you'll need to add similar code. This readme does not contain instructions for such modification. Either look at this contrib's files for hints or post on appropriate forums for assistance.
4) 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.
2 Nov 2006, 10:02 PM
#4
s_mack avatar

s_mack

Totally Zenned

Join Date:
Jun 2005
Location:
Kelowna, BC Canada
Posts:
1,033
Plugin Contributions:
4

Re: stockFilter for 1.3.5

fyi. works fine with 1.3.6

  • Steven
24 Nov 2006, 12:55 AM
#5
s_mack avatar

s_mack

Totally Zenned

Join Date:
Jun 2005
Location:
Kelowna, BC Canada
Posts:
1,033
Plugin Contributions:
4

Re: stockFilter for 1.3.5

Either this works perfectly and nobody is complaining... or nobody is using (although its been downloaded over 200 times).

Anyway, I've uploaded a new version just now (see link above) after adding support to the "New Products", "Featured Products", "All Products", and "Specials" pages. I didn't support these previously because I didn't use them. If you don't use them (configurable in admin under Layout Settings) then you don't need to bother upgrading.

Please note that for the Specials page to work, a core file must be modified (although it is minor). This means that if/when Zen upgrades ZenCart and modifies that file, that this contrib will be destroyed for that page (until I make a new version). It is a VERY simple change... I just had to add the following code to the /includes/modules/pages/specials/main_template_vars.php file (this file is likely to be over-rideable in the future, but for now is not so I had to edit it directly):```
// Begin stockFilter code
// Unfortunately, this is in a core file. The structure of the specials page is such that it was impossible
// to get around this core edit.
if (($_SESSION['stockFilter'] == 'in_stock') && ((!$stock_filter_excluded) || ($stock_filter_unfilter_sideboxes != true))) {
$specials_query_raw = str_replace('p.products_status = '1'', 'p.products_status = 1 and p.products_quantity > 0', $specials_query_raw);
}
// End stockFilter code


 - Steven
26 Nov 2006, 5:32 PM
#6
pixxi avatar

pixxi

Totally Zenned

Join Date:
Jan 2004
Location:
UK
Posts:
1,065
Plugin Contributions:
1

Re: stockFilter for 1.3.5

Hi Steven,

Just an FYI - the download link seems to be giving a 'file not found' error.

26 Nov 2006, 5:40 PM
#7
s_mack avatar

s_mack

Totally Zenned

Join Date:
Jun 2005
Location:
Kelowna, BC Canada
Posts:
1,033
Plugin Contributions:
4

Re: stockFilter for 1.3.5

I just tried it... both the one above that links directly to the downloads section, and the "download now" link once you get there... both work. So probably just a glitch at ZenCart during the moment you were trying to get it.

  • Steven
17 Apr 2011, 6:35 PM
#8
gmrm avatar

gmrm

Zen Follower

Join Date:
Apr 2009
Location:
Oxford UK
Posts:
192
Plugin Contributions:
0

Re: stockFilter for 1.3.5

Is the author of this mod still about as i cannot get this to work

17 Apr 2011, 9:04 PM
#9
s_mack avatar

s_mack

Totally Zenned

Join Date:
Jun 2005
Location:
Kelowna, BC Canada
Posts:
1,033
Plugin Contributions:
4

Re: stockFilter for 1.3.5

I am, but I can't help a "cannot get this to work" post.

17 Apr 2011, 9:10 PM
#10
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: stockFilter for 1.3.5

Yes, he is still around.
Several of the files in the mod have been updated in recent releases of Zen Cart, some in ways that make the mod versions incompatible with ZC 1.3.9h. It would probably not be a hard job to merge and update the mod files, but it would take time and care.

Yup, I guess he really is around :)

18 Apr 2011, 10:40 PM
#11
gmrm avatar

gmrm

Zen Follower

Join Date:
Apr 2009
Location:
Oxford UK
Posts:
192
Plugin Contributions:
0

Re: stockFilter for 1.3.5

Hi s_mack this mod is a brilliant idea, i have added this to my store here http://www.gloopy.co.uk but when i add the code to ./includes/templates/YOUR_TEMPLATE/sideboxes/tpl_categories.php it will not show my store so i left that page out.

Also if you try it sometimes it works brilliantly but sometimes it does not work at all eg :-

sometimes when i click on filter in stock only it reverts back to show all items. It seems to be luck whether it works or not. Please take a look and tell me what you think and many thanks for getting back to me.

"I am, but I can't help a "cannot get this to work" post. "

sorry i only posted that first to see if you were still about :0

18 Apr 2011, 10:41 PM
#12
gmrm avatar

gmrm

Zen Follower

Join Date:
Apr 2009
Location:
Oxford UK
Posts:
192
Plugin Contributions:
0

Re: stockFilter for 1.3.5

also when it activates it adds /stock_filter/in_stock to the end of the page your on, will google see that as a new page when its crawling my site ???

18 Apr 2011, 11:04 PM
#13
gmrm avatar

gmrm

Zen Follower

Join Date:
Apr 2009
Location:
Oxford UK
Posts:
192
Plugin Contributions:
0

Re: stockFilter for 1.3.5

when i add the code to the templates files i get this

1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'limit 10' at line 1
in:
[ limit 10]

18 Apr 2011, 11:14 PM
#14
s_mack avatar

s_mack

Totally Zenned

Join Date:
Jun 2005
Location:
Kelowna, BC Canada
Posts:
1,033
Plugin Contributions:
4

Re: stockFilter for 1.3.5

My mod doesn't do that to your url, so that must be another mod. Something SEO related, I imagine. That could also be the source of your troubles.

FYI - I haven't even LOOKED at this code in the 4.5 years since I last posted. I can't remember at all what I did and I don't even have a copy of it on my hard drive any more.

I'm sorry, but considering the age... how many changes there have been to the core... the fact you're mixing it with other contributions... and how busy I am with other things right now... I really can't offer any support on this. You're free to take the code and do as you will with it, but I'm not going to have the time to help out. I mean really, at this point, I'd be no more useful than someone looking at it fresh because its been so long. I doubt I'll even recognize my own code. Id probably laugh at it :) But I wouldn't recognize it.

Best of luck.

  • Steven

ps. And FYI - the only reason I responded to your "is he here" post was because I still have this topic subscribed from years ago. I'm not really "here" and I've pretty well completely moved away from Zen related development.

18 Apr 2011, 11:20 PM
#15
gmrm avatar

gmrm

Zen Follower

Join Date:
Apr 2009
Location:
Oxford UK
Posts:
192
Plugin Contributions:
0

Re: stockFilter for 1.3.5

s_mack:

My mod doesn't do that to your url, so that must be another mod. Something SEO related, I imagine. That could also be the source of your troubles.

This is the only stock mod i have installed and if you click on it on any page it adds this if you click in stock :-

stock_filter/in_stock/

and if i choose out of stock :-

stock_filter/all

hmmm maybe some one can help me

18 Apr 2011, 11:37 PM
#16
s_mack avatar

s_mack

Totally Zenned

Join Date:
Jun 2005
Location:
Kelowna, BC Canada
Posts:
1,033
Plugin Contributions:
4

Re: stockFilter for 1.3.5

It may be your only stock related mod... but I'm certain its an SEO related mod doing that. Or perhaps an SEO option in the core that's been introduced since the last time I've used Zen?

18 Apr 2011, 11:40 PM
#17
gmrm avatar

gmrm

Zen Follower

Join Date:
Apr 2009
Location:
Oxford UK
Posts:
192
Plugin Contributions:
0

Re: stockFilter for 1.3.5

I have Simple SEO URL but when i turn that off it adds this :-

?stock_filter=in_stock
?stock_filter=all

does anyone else use this mod ??

18 Apr 2011, 11:43 PM
#18
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: stockFilter for 1.3.5

If you have the (v1.3.9 feature) "canonical" link specified for these pages, it will probably not matter that the URL is changing, as search engines will use the proper version for indexing.

18 Apr 2011, 11:47 PM
#19
gmrm avatar

gmrm

Zen Follower

Join Date:
Apr 2009
Location:
Oxford UK
Posts:
192
Plugin Contributions:
0

Re: stockFilter for 1.3.5

Hi gjh42 yes i am using 1.3.9h but the mod isn't working as planned anyway and i don't know a lot about php so think i will have to get back to the drawing board as the author has abandoned this mod.

many thanks anyway

18 Apr 2011, 11:55 PM
#20
gmrm avatar

gmrm

Zen Follower

Join Date:
Apr 2009
Location:
Oxford UK
Posts:
192
Plugin Contributions:
0

Re: stockFilter for 1.3.5

How could i implement this code

<?php $content = ''; $content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent centeredContent">'; $content .= zen_draw_form('stock_filter', zen_href_link(basename(ereg_replace('.php','', $PHP_SELF)), '', $request_type, false), 'get'); $content .= zen_draw_pull_down_menu('stock_filter', array(array('id' => 'all', 'text' => TEXT_STOCK_FILTER_OFF), array('id' => 'in_stock', 'text' => TEXT_STOCK_FILTER_ON)), $_SESSION['stockFilter'], 'onchange="this.form.submit();" style="width: 90%;"') . $hidden_get_variables . zen_hide_session_id(); $content .= '</form></div>'; ?>

to add to the product listing pages only ???