Author Topic: A module to let user chose whether (s)he wants to see Out of Stock items  (Read 3604 times)

  • Beginner
  • *
  • Posts: 2
By default, only the administrator can chose whether or not products out of stock are to be shown.

I've developed a little module to let users chose whether they want to see or not Out of Stock items. This module requieres some little changes in core files. Here they are.

1/ Download zip file with module and class file.

3/ In administrator\components\com_virtuemart\global.php, add at row 105

4/ Replace every occurrence of
if( getShowOnlyInStock()) {

That is in following files:

5/ Add the following at beginning (row 40 i.e.)
  of administrator\components\com_virtuemart\html\shop.browse.php
$show_not_in_stock= $vmInputFilter->safeSQL( vmGet( $_REQUEST, 'shownotinstock', null ));
if ($show_not_in_stock==0) {
} elseif ($show_not_in_stock==1) {

- Louis Bronne

  • Beginner
  • *
  • Posts: 2
In point 5)
better use
$show_not_in_stock= $vmInputFilter->safeSQL( vmGet( $_REQUEST, 'shownotinstock', 2 ));
$show_not_in_stock= $vmInputFilter->safeSQL( vmGet( $_REQUEST, 'shownotinstock', null ));

In mod_virtuemart_shownotinstock.php, code for form_action was also erroneous. Here is the correction:
if (!strpos($_SERVER['QUERY_STRING'],"page=shop.browse")) {
   $sess->purl( $mm_action_url."index.php?".$_SERVER['QUERY_STRING']."&shownotinstock=".($show_not_in_stock?0:1));
} else {
   $sess->purl($mm_action_url."index.php?page=shop.browse&shownotinstock=".($show_not_in_stock?0:1) );


  • Jr. Member
  • **
  • Posts: 87
Re: A module to let user chose whether (s)he wants to see Out of Stock items
« Reply #2 on: September 14, 2010, 17:15:29 pm »
Can you please review your posting if you have forgotten something? The thing is that:

1. All codes correctly inserted, no breaking site, there seem to be no errors in the code or changes


It does not work on the browse page

this is what happens in the url:

Code: [Select]
When changing the 0 to a 1 first, also nothing happens.

Whenever hitting the change this button another "&shownotinstock=0&Itemid=195" is added to the url, the site reloads but nothing else happens. The text changes to "not shown" or "shown" but still all products are shown on the browse page. Is there maybe one more file in the browse region that needs to be adjusted as it works in the modules just perfectly?


It works in a module, only products in stock are shown

Is there a way that you can change if products out of stock are shown in modules now, as after the changes those wont be displayed in modules anymore at all?

Like adding some parameters to the module XML to decide if to show products in stock or not for individual modules. Some module should also show products out of stock while some should only display products in stock?


  • Jr. Member
  • **
  • Posts: 87
Re: A module to let user chose whether (s)he wants to see Out of Stock items
« Reply #3 on: October 11, 2010, 17:36:20 pm »
Okay, I do not know if anyone is watching this topic, but it is really a valuable one, so I now know that this error is caused by login status. When I enter the site as logged in user the module and function does not work as I described above. When not being a registered user the function works. As I rarely check the store not being logged in this error seemed to be a global one.

Does anyone have a solution to get over this restriction that only logged out users can use this function?

P.S.: The issue with url creation still persists.