Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / General Questions / Is there a way to show products sold in it's own category?

Is there a way to show products sold in it's own category?

Started by mespe on 30 Jun 2015, 10:00 PM · Views: 1,305

Results 1 to 7 of 7
30 Jun 2015, 10:00 PM
#1
mespe avatar

mespe

Zen Follower

Join Date:
Sep 2014
Location:
ohio
Posts:
216
Plugin Contributions:
0

Post #1 by mespe

I've noticed that once an item sells it is no longer available to view by either the customer or me.
I would like to view the listing, as I usually have multiple pictures.
So is there an easy way to create a "Sold" category that any part sold gets moved to?
I do not want to clutter up my store with a bunch of sold items among items for sale.

30 Jun 2015, 10:03 PM
#2
ajeh avatar

ajeh

Oba-san

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

Post #2 by ajeh

In the settings for Configuration ... Stock ...

Set to 1 for ON

Products status in Catalog when out of stock should be set to
Show Products when out of stock

0= set product status to OFF
1= leave product status ON

Set to 1 for ON

Show Sold Out Image in place of Add to Cart
Show Sold Out Image instead of Add to Cart Button

0= off
1= on

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!

1 Jul 2015, 2:03 AM
#3
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Post #3 by kobra

So is there an easy way to create a "Sold" category that any part sold gets moved to?
I do not want to clutter up my store with a bunch of sold items among items for sale.
In addition to what Ajeh posted
You can create a category with a name you prefer maybe "sold" but you then have to manually move these items into it

Zen-Venom Get Bitten

1 Jul 2015, 12:17 PM
#4
ajeh avatar

ajeh

Oba-san

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

Post #4 by ajeh

You could customize the orders.php class to move Products to the Sold Out Category when they sell out on the Order ...

Do you use Linked Products?

Do you want the Products when they sell out removed from their current Category(ies) and only be in the Sold Out Category?

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!

2 Jul 2015, 5:38 PM
#5
mespe avatar

mespe

Zen Follower

Join Date:
Sep 2014
Location:
ohio
Posts:
216
Plugin Contributions:
0

Post #5 by mespe

My replies in bold

Ajeh:

You could customize the orders.php class to move Products to the Sold Out Category when they sell out on the Order ...

Do you use Linked Products?

Do you want the Products when they sell out removed from their current Category(ies) and only be in the Sold Out Category?

customize the orders.php class to move Products to the Sold Out Category when they sell out on the Order <--- YES How?
And yes I use linked products, for example glass has it's own category, but is also linked to the vehicle type

Do you want the Products when they sell out removed from their current Category(ies) and only be in the Sold Out Category? YES

3 Jul 2015, 2:41 PM
#6
ajeh avatar

ajeh

Oba-san

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

Post #6 by ajeh

You could try this, after backing up your database and the file orders.php, by adding the code in RED:
/includes/classes/order.php

          //        if ( ($stock_left < 1) && (STOCK_ALLOW_CHECKOUT == 'false') ) {
          if ($stock_left <= 0) {
[B]
// bof: move Product to Sold Out Categories
$categories_sold_out = 66; // Set to Sold Out categories_id
$delete_sql = "DELETE from " . TABLE_PRODUCTS_TO_CATEGORIES . " WHERE products_id ='" . zen_get_prid($this->products[$i]['id']) . "'";
$db->Execute($delete_sql);
$add_sql = "INSERT INTO " . TABLE_PRODUCTS_TO_CATEGORIES . "(products_id, categories_id) values (" . zen_get_prid($this->products[$i]['id']) . ", " . $categories_sold_out . ")";
$db->Execute($add_sql);
$update_sql = "UPDATE " . TABLE_PRODUCTS . " SET master_categories_id = " . $categories_sold_out . " WHERE products_id = '" . zen_get_prid($this->products[$i]['id']) . "'";
$db->Execute($update_sql);
// eof: move Product to Sold Out Categories
[/B]
            // only set status to off when not displaying sold out
            if (SHOW_PRODUCTS_SOLD_OUT == '0') {
              $db->Execute("update " . TABLE_PRODUCTS . " set products_status = 0 where products_id = '" . zen_get_prid($this->products[$i]['id']) . "'");
            }

Be sure to first Create your Sold Out Category and then edit this code and use that categories_id for this setting where it is set currently to 66 to your own categories_id:

[B]$categories_sold_out = 66; // Set to Sold Out categories_id
[/B]

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 Jul 2015, 7:42 PM
#7
mespe avatar

mespe

Zen Follower

Join Date:
Sep 2014
Location:
ohio
Posts:
216
Plugin Contributions:
0

Post #7 by mespe

Ajeh:

You could try this, after backing up your database and the file orders.php, by adding the code in RED:
/includes/classes/order.php

      //        if ( ($stock_left < 1) && (STOCK_ALLOW_CHECKOUT == 'false') ) {
      if ($stock_left <= 0) {

[B]
// bof: move Product to Sold Out Categories
$categories_sold_out = 66; // Set to Sold Out categories_id
$delete_sql = "DELETE from " . TABLE_PRODUCTS_TO_CATEGORIES . " WHERE products_id ='" . zen_get_prid($this->products[$i]['id']) . "'";
$db->Execute($delete_sql);
$add_sql = "INSERT INTO " . TABLE_PRODUCTS_TO_CATEGORIES . "(products_id, categories_id) values (" . zen_get_prid($this->products[$i]['id']) . ", " . $categories_sold_out . ")";
$db->Execute($add_sql);
$update_sql = "UPDATE " . TABLE_PRODUCTS . " SET master_categories_id = " . $categories_sold_out . " WHERE products_id = '" . zen_get_prid($this->products[$i]['id']) . "'";
$db->Execute($update_sql);
// eof: move Product to Sold Out Categories
[/B]

// only set status to off when not displaying sold out
if (SHOW_PRODUCTS_SOLD_OUT == '0') {
$db->Execute("update " . TABLE_PRODUCTS . " set products_status = 0 where products_id = '" . zen_get_prid($this->products[$i]['id']) . "'");
}

> 
> Be sure to first Create your Sold Out Category and then edit this code and use that categories_id for this setting where it is set currently to 66 to your own categories_id:
> ```
[B]$categories_sold_out = 66; // Set to Sold Out categories_id
[/B]

Thanks, I will try that but first a few questions (so I can hopefully learn some code,,,)

$categories_sold_out = SOLD ITEMS; //$categories_sold_out identifies a string called SOLD ITEMS

Wow the next lines totally confuse me,,,

At any rate, I manually moved the few items sold, but now my "Products" count is inaccurate, as it's still counting the sold items as active inventory. If I disable the item, then they don't display in my store. (Think I'll go fishing with all the worms that are crawling out of the can,,,) so I need to add code to remove the number of items in the "SOLD ITEMS" category, unless there's a check box for do not include items in this category to be added to the product count, or other work around.

Thanks for the help so far Ajeh