Forums / Templates, Stylesheets, Page Layout / Make a product that is sold out not appear in listings, sideboxes

Make a product that is sold out not appear in listings, sideboxes

Started by dgent on 27 Feb 2012, 11:54 AM · Views: 2,273

Results 1 to 20 of 21
27 Feb 2012, 11:54 AM
#1
dgent avatar

dgent

Totally Zenned

Join Date:
Nov 2009
Location:
UK
Posts:
1,117
Plugin Contributions:
0

Make a product that is sold out not appear in listings, sideboxes

Is there any way to make a product which is marked as sold out, not appear in product listings, centreboxes etc.

I don't want to delete the product or turn it off as that makes a page not found, so I want to mark it as sold out, but not come up in the current products listings on my sites.

27 Feb 2012, 2:47 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Make a product that is sold out not appear in listings, sideboxes

For the Product Listing, edit the file:
/includes/index_filters/default_filter.php

and where you find in each of the SELECT statements:

       where p.products_status = 1

add to it:

       where p.products_status = 1
       and p.products_quantity > 0

For the Centerboxes, you would need to do the same thing, example for the Featured Products centerbox edit the file, using your templates and overrides:
/includes/modules/featured_products.php

copy to:
/includes/modules/your_templates_dir/featured_products.php

and add the same thing to each of the SELECT statements:

                           and p.products_status = 1 and f.status = 1

to read:

                           and p.products_status = 1 and f.status = 1
                           and p.products_quantity > 0

and that will prevent the display of Sold Out Products ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

29 Feb 2012, 2:09 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Make a product that is sold out not appear in listings, sideboxes

Thanks for the update that this worked for you ... :smile:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

3 Mar 2012, 8:30 PM
#5
dgent avatar

dgent

Totally Zenned

Join Date:
Nov 2009
Location:
UK
Posts:
1,117
Plugin Contributions:
0

Re: Make a product that is sold out not appear in listings, sideboxes

Actually, couple of issues. Those products still show in searches (and not for those particular products - but they just happen to have a keyword used in it, ie 'dress') and they still show in the new products page and all products page.

Any way of preventing this?

3 Mar 2012, 10:20 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Make a product that is sold out not appear in listings, sideboxes

Peek at the:
/includes/modules/pages/advanced_search_result/header_php.php

$where_str = " WHERE (p.products_status = 1
               AND p.products_id = pd.products_id
               AND pd.language_id = :languagesID
               AND p.products_id = p2c.products_id
               AND p2c.categories_id = c.categories_id ";

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

5 Mar 2012, 11:33 PM
#7
renz avatar

renz

Zen Follower

Join Date:
Jun 2006
Posts:
439
Plugin Contributions:
0

Re: Make a product that is sold out not appear in listings, sideboxes

Hi Ajeh,
Following your above advice, I was sucessfull in removing"Sold Out" items from the "Product Listings", and "Advanced Search Results".

I have not been able to prevent them showing on the "Specials" "Featured""All Products"

I Have recently added this line:
$listing_sql .= " order by IF( p.products_quantity >0, 1, 0 ) DESC , p.products_sort_order , pd.products_name";
To: /includes/index_filters/default_filter.php
Around line 107. Though I dont think this would have an effect on the other pages I am trying to stop the sold out items showing.
Thanks
Regards
Renz

6 Mar 2012, 12:28 AM
#8
renz avatar

renz

Zen Follower

Join Date:
Jun 2006
Posts:
439
Plugin Contributions:
0

Re: Make a product that is sold out not appear in listings, sideboxes

Update..

I have now done it for "All Products" & "New Products"

Nice and easy.

These though are not playing nice. (I actually deleted/renamed them and they still work, so for some reason I am not editing the right ones, but I triple checked that I am going to the below file structure locations)

Featured….
includes/modules/theme163/featured_products.php
and p.products_quantity > 0

Specials…
You need to customize the code for the:
/includes/modules/pages/specials/main_template_vars.php

and add to the WHERE statement something like:
AND p.products_quantity > 0

I look fwd to any assistance.
Regards
Renz

6 Mar 2012, 1:23 AM
#9
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Make a product that is sold out not appear in listings, sideboxes

On the:
/includes/modules/pages/specials/main_template_vars.php

You are using:

  $specials_query_raw = "SELECT p.products_id, p.products_image, pd.products_name,
                          p.master_categories_id
                         FROM (" . TABLE_PRODUCTS . " p
                         LEFT JOIN " . TABLE_SPECIALS . " s on p.products_id = s.products_id
                         LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id )
                         WHERE p.products_id = s.products_id and p.products_id = pd.products_id and p.products_status = '1'
                         AND s.status = 1
                         AND p.products_quantity > 0
                         AND pd.language_id = :languagesID
                         ORDER BY s.specials_date_added DESC";

and added to both SELECT statements:

  $featured_products_query = "select distinct p.products_id, p.products_image, pd.products_name, p.master_categories_id
                           from (" . TABLE_PRODUCTS . " p
                           left join " . TABLE_FEATURED . " f on p.products_id = f.products_id
                           left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id )
                           where p.products_id = f.products_id
                           and p.products_id = pd.products_id
                           and p.products_status = 1 and f.status = 1
                         AND p.products_quantity > 0 
                           and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";
    $featured_products_query = "select distinct p.products_id, p.products_image, pd.products_name, p.master_categories_id
                                from (" . TABLE_PRODUCTS . " p
                                left join " . TABLE_FEATURED . " f on p.products_id = f.products_id
                                left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id)
                                where p.products_id = f.products_id
                                and p.products_id = pd.products_id
                                and p.products_status = 1 and f.status = 1
                         AND p.products_quantity > 0 
                                and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
                                and p.products_id in (" . $list_of_products . ")";

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

6 Mar 2012, 1:59 AM
#10
renz avatar

renz

Zen Follower

Join Date:
Jun 2006
Posts:
439
Plugin Contributions:
0

Re: Make a product that is sold out not appear in listings, sideboxes

I am sorry Ajeh,
I really struggle to follow what you are telling me...I am limited with Scripts to.
Find/Change this goes there.
I dont understand the 2 select statements.
Also the example line of mine:
WHERE p.products_id = s.products_id and p.products_id = pd.products_id and p.products_status = '1'
AND s.status = 1
AND p.products_quantity > 0
AND pd.language_id = :languagesID
**
Looks different to yours..**where p.products_id = f.products_id
and p.products_id = pd.products_id
and p.products_status = 1 and f.status = 1
AND p.products_quantity > 0
and pd.language_id = '" .

So its very hard for me to figure it out.
Thanks
RR

6 Mar 2012, 2:31 AM
#11
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Make a product that is sold out not appear in listings, sideboxes

What version of Zen Cart are you using?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

6 Mar 2012, 2:37 AM
#12
renz avatar

renz

Zen Follower

Join Date:
Jun 2006
Posts:
439
Plugin Contributions:
0

Re: Make a product that is sold out not appear in listings, sideboxes

Hi I am on 1.3.8a

(Sorry not able to upgarde at the moment, not i my capacity)

Thanks
RR

6 Mar 2012, 2:43 AM
#13
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Make a product that is sold out not appear in listings, sideboxes

Post the whole SELECT statement that you have in your code ... it is not making a lot of sense why it does not work for you to add:
AND p.products_quantity > 0

to the WHERE portion of the SELECT statements ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

6 Mar 2012, 2:48 AM
#14
renz avatar

renz

Zen Follower

Join Date:
Jun 2006
Posts:
439
Plugin Contributions:
0

Re: Make a product that is sold out not appear in listings, sideboxes

<?php /** * Specials * * @package page * @copyright Copyright 2003-2007 Zen Cart Development Team * @copyright Portions Copyright 2003 osCommerce * @license <http://www.zen-cart.com/license/2_0.txt> GNU Public License V2.0 * @version $Id: main_template_vars.php 6912 2007-09-02 02:23:45Z drbyte $ */ if (MAX_DISPLAY_SPECIAL_PRODUCTS > 0 ) { $specials_query_raw = "SELECT p.products_id, p.products_image, pd.products_name, p.master_categories_id FROM (" . TABLE_PRODUCTS . " p LEFT JOIN " . TABLE_SPECIALS . " s on p.products_id = s.products_id LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id ) WHERE p.products_id = s.products_id and p.products_id = pd.products_id and p.products_status = '1' AND s.status = 1 AND p.products_quantity > 0 AND pd.language_id = :languagesID ORDER BY s.specials_date_added DESC"; $specials_query_raw = $db->bindVars($specials_query_raw, ':languagesID', $_SESSION['languages_id'], 'integer'); $specials_split = new splitPageResults($specials_query_raw, MAX_DISPLAY_SPECIAL_PRODUCTS); $specials = $db->Execute($specials_split->sql_query); $row = 0; $col = 0; $list_box_contents = array(); $title = ''; $num_products_count = $specials->RecordCount(); if ($num_products_count) { if ($num_products_count < SHOW_PRODUCT_INFO_COLUMNS_SPECIALS_PRODUCTS || SHOW_PRODUCT_INFO_COLUMNS_SPECIALS_PRODUCTS==0 ) { $col_width = floor(100/$num_products_count); } else { $col_width = floor(100/SHOW_PRODUCT_INFO_COLUMNS_SPECIALS_PRODUCTS); } $list_box_contents = array(); while (!$specials->EOF) { $products_price = zen_get_products_display_price($specials->fields['products_id']); $specials->fields['products_name'] = zen_get_products_name($specials->fields['products_id']); $list_box_contents[$row][$col] = array('params' => 'class="specialsListBoxContents"' . ' ' . 'style="width:' . $col_width . '%;"', 'text' => '<a href="' . zen_href_link(zen_get_info_page($specials->fields['products_id']), 'cPath=' . zen_get_generated_category_path_rev($specials->fields['master_categories_id']) . '&products_id=' . $specials->fields['products_id']) . '">' . (($specials->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : zen_image(DIR_WS_IMAGES . $specials->fields['products_image'], $specials->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>') . '<br /><a href="' . zen_href_link(zen_get_info_page($specials->fields['products_id']), 'cPath=' . zen_get_generated_category_path_rev($specials->fields['master_categories_id']) . '&products_id=' . $specials->fields['products_id']) . '">' . $specials->fields['products_name'] . '</a><br />' . $products_price); $col ++; if ($col > (SHOW_PRODUCT_INFO_COLUMNS_SPECIALS_PRODUCTS - 1)) { $col = 0; $row ++; } $specials->MoveNext(); } require($template->get_template_dir('tpl_specials_default.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_specials_default.php'); } } ?>
6 Mar 2012, 2:54 AM
#15
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Make a product that is sold out not appear in listings, sideboxes

I am sorry but I am not seeing the problem in the code ...

I do not have a functional v1.3.8 to fool with to see if there is something to break this but it works on v1.3.9h and v1.5 ... :unsure:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

6 Mar 2013, 10:06 AM
#16
solo_400 avatar

solo_400

Zen Follower

Join Date:
Aug 2009
Posts:
369
Plugin Contributions:
0

Re: Make a product that is sold out not appear in listings, sideboxes

I hope to have a little help from you .

After I eliminate all sold products for being listed by applying advices on this thread I still have an Issue . When I click on next product button ( product info page ) products already sold are coming out . Do you know which file should a check in order to prevent that ?

Thx

6 Mar 2013, 2:17 PM
#17
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Make a product that is sold out not appear in listings, sideboxes

If you do not want Sold Out Products in the Listings, sideboxes or in the Previous/Next ... then do you want Sold Out Products to ever show?

If not, why don't you set your site up that Sold Out Products are marked as Out of Stock and they are turned off an do not show ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

6 Mar 2013, 7:47 PM
#18
solo_400 avatar

solo_400

Zen Follower

Join Date:
Aug 2009
Posts:
369
Plugin Contributions:
0

Re: Make a product that is sold out not appear in listings, sideboxes

I need products remain on stock in order to have google working links and to avoid a loop problem ( another own trhread ) but hide them from categories listing . Everything works ok except previous/next . Is there any solution ?

7 Mar 2013, 1:21 AM
#19
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Make a product that is sold out not appear in listings, sideboxes

Try customizing the file:
/includes/modules/product_prev_next.php

using your templates and overrides and add the code in RED:

  $sql = "select p.products_id, p.products_model, p.products_price_sorter, pd.products_name, p.products_sort_order
          from   " . TABLE_PRODUCTS . " p, "
  . TABLE_PRODUCTS_DESCRIPTION . " pd, "
  . TABLE_PRODUCTS_TO_CATEGORIES . " ptc
          where  [B]p.products_quantity >= 1 and [/B]p.products_status = '1' and p.products_id = pd.products_id and pd.language_id= '" . (int)$_SESSION['languages_id'] . "' and p.products_id = ptc.products_id and ptc.categories_id = '" . (int)$current_category_id . "'" .
  $prev_next_order;

and see if that does what you want where you can still get to the product_info page for the Products with products_quantity 0, like a spider would, but not get to these products using the Previous/Next ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

7 Mar 2013, 9:25 AM
#20
solo_400 avatar

solo_400

Zen Follower

Join Date:
Aug 2009
Posts:
369
Plugin Contributions:
0

Re: Make a product that is sold out not appear in listings, sideboxes

Thank you so much Linda , worked perfect .

Have anice day !