Results 1 to 10 of 10
  1. #1
    Join Date
    Jul 2011
    Posts
    107
    Plugin Contributions
    0

    Default Is there a way to mark an entire category at out of stock?

    Hi there :)

    I am wondering if there is a somewhat easy way to mark an entire category as Out of Stock? I am currently out of stock of material I require to make every item that I have in a particular category. The only way I have been able to stop customers from ordering from that category is to change my store status to Showcase with Prices. The problem with doing this is that I have other categories in which I do not require the out of stock material that I can still process. I don't want to disable the category all together either. Is there any way I can indicate a particular category is out of stock, still have the category showing but each item would be marked as out of stock and allow ordering of items that ARE in stock?? I hope that makes sense..lol! I'll add more specific details below in case it's confusing..lol!

    Thanks :)

    Specific details: I make personalized chocolate bar wrappers, wine bottle labels, invitations etc. I have run out of foil that I use to overwrap the chocolate bar before wrapping with the personalized wrapper, therefore, it basically renders all of my chocolate bar wrappers as 'out of stock' or 'unavailable' since I am out of stock on a key material. That said, all of my other items are still available since they don't require the overwrap.

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Is there a way to mark an entire category at out of stock?

    Is this Category the master_categories_id of all of these 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!

  3. #3
    Join Date
    Jul 2011
    Posts
    107
    Plugin Contributions
    0

    Default Re: Is there a way to mark an entire category at out of stock?

    Yes, it is the master category and then contains sub categories. So basically, the main category is 'Chocolate Bar Wrappers' and then that category contains sub categories such as 'Wedding', 'Birthday', 'Baby Shower' etc. i would like to know if there is a way to set the main (top) category as Out of Stock or Currently Unavailable.

    Thanks :)

  4. #4
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: Is there a way to mark an entire category at out of stock?

    Well may have a code way to do this... Could create a file in your admin directory:

    Say call it

    disable_category.php

    to "activate" whichever option chosen below, then once logged into the admin goto/open:

    admin/disable_category.php?cat_disable=10

    to perform the applicable action from below for the category and all of the product below it that has the category_id of 10...


    Code:
    <?php
    require('includes/application_top.php');
    
    $prod_list = array();
    
    if (isset($_GET['cat_disable']) && $_GET['cat_disable'] != '' && is_numeric($_GET['cat_disable'])) {
      $cat_to_disable = $_GET['cat_disable'];
    } else {
      $cat_to_disable = false;
    }
    
    if ($cat_to_disable !== false) {
      $prod_list = zen_get_categories_products_list($cat_to_disable);
    }
    
    foreach ($prod_list as $prod_id => $cat) {
      $db->Execute('update ' . TABLE_PRODUCTS . ' p set p.products_status = 0 where p.products_id = ' . (int)$prod_id);
    }
    Or you could disable the product category which would disable the product...
    This will disable the product from view (in a default install). If instead you want to set the quantity available to 0 and you have your store setup to not disable the product when quantity is 0, then:


    Code:
    <?php
    require('includes/application_top.php');
    
    $prod_list = array();
    
    if (isset($_GET['cat_disable']) && $_GET['cat_disable'] != '' && is_numeric($_GET['cat_disable'])) {
      $cat_to_disable = $_GET['cat_disable'];
    } else {
      $cat_to_disable = false;
    }
    
    if ($cat_to_disable !== false) {
      $prod_list = zen_get_categories_products_list($cat_to_disable);
    }
    
    foreach ($prod_list as $prod_id => $cat) {
      $db->Execute('update ' . TABLE_PRODUCTS . ' p set p.products_quantity = 0 where p.products_id = ' . (int)$prod_id);
    }
    Or... If you replace the call_for_price icon with your out-of-stock notification, then:

    Code:
    <?php
    require('includes/application_top.php');
    
    $prod_list = array();
    
    if (isset($_GET['cat_disable']) && $_GET['cat_disable'] != '' && is_numeric($_GET['cat_disable'])) {
      $cat_to_disable = $_GET['cat_disable'];
    } else {
      $cat_to_disable = false;
    }
    
    if ($cat_to_disable !== false) {
      $prod_list = zen_get_categories_products_list($cat_to_disable);
    }
    
    foreach ($prod_list as $prod_id => $cat) {
      $db->Execute('update ' . TABLE_PRODUCTS . ' p set p.product_is_call = 1 where p.products_id = ' . (int)$prod_id);
    }
    This will set the product to still being "available" (shown on screen) but requires calling for price instead of providing a price.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    Jul 2011
    Posts
    107
    Plugin Contributions
    0

    Default Re: Is there a way to mark an entire category at out of stock?

    Quote Originally Posted by mc12345678 View Post
    Well may have a code way to do this... Could create a file in your admin directory:

    Say call it

    disable_category.php

    to "activate" whichever option chosen below, then once logged into the admin goto/open:

    admin/disable_category.php?cat_disable=10

    to perform the applicable action from below for the category and all of the product below it that has the category_id of 10...


    Code:
    <?php
    require('includes/application_top.php');
    
    $prod_list = array();
    
    if (isset($_GET['cat_disable']) && $_GET['cat_disable'] != '' && is_numeric($_GET['cat_disable'])) {
      $cat_to_disable = $_GET['cat_disable'];
    } else {
      $cat_to_disable = false;
    }
    
    if ($cat_to_disable !== false) {
      $prod_list = zen_get_categories_products_list($cat_to_disable);
    }
    
    foreach ($prod_list as $prod_id => $cat) {
      $db->Execute('update ' . TABLE_PRODUCTS . ' p set p.products_status = 0 where p.products_id = ' . (int)$prod_id);
    }
    Thanks mc12345678 for your response. I like the sounds of the first option you outlined but I'm wondering if you might need to dumb it down a little for me because what I did didn't seem to work...lol! I copied the code you provided and created a new file under /public_html/zcadmin called Disable_category.php. I then logged into my admin but I can't seem to find it anywhere to edit/activate. Clearly I've done it wrong

  6. #6
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: Is there a way to mark an entire category at out of stock?

    Quote Originally Posted by jcrewe View Post
    Thanks mc12345678 for your response. I like the sounds of the first option you outlined but I'm wondering if you might need to dumb it down a little for me because what I did didn't seem to work...lol! I copied the code you provided and created a new file under /public_html/admin called Disable_category.php. I then logged into my admin but I can't seem to find it anywhere to edit/activate. Clearly I've done it wrong
    So, once you have logged in to the admin, in your browser use the path described above... Once complete press your back button to go back to your normal admin...

    So on login your browser likely has something like: http s :// yourstore . Com/YOUR_SECRET_ADMIN/index.php

    Change index.php to Disable_category.php and also add the parameter ?cat_disable=20 (where 20 is the category_id at the top of the tree of product to modify)

    So:
    http s :// yourstore . Com/YOUR_SECRET_ADMIN/Disable_category.php?cat_disable=25

    Would do whatever was programmed to category_id 25
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #7
    Join Date
    Jul 2011
    Posts
    107
    Plugin Contributions
    0

    Default Re: Is there a way to mark an entire category at out of stock?

    Quote Originally Posted by mc12345678 View Post
    So, once you have logged in to the admin, in your browser use the path described above... Once complete press your back button to go back to your normal admin...

    So on login your browser likely has something like: http s :// yourstore . Com/YOUR_SECRET_ADMIN/index.php

    Change index.php to Disable_category.php and also add the parameter ?cat_disable=20 (where 20 is the category_id at the top of the tree of product to modify)

    So:
    http s :// yourstore . Com/YOUR_SECRET_ADMIN/Disable_category.php?cat_disable=25

    Would do whatever was programmed to category_id 25
    When I do that, I get a blank white screen as if the path goes nowhere and then when I check my site you can still order a product from that category

  8. #8
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: Is there a way to mark an entire category at out of stock?

    Okay, while I'd like to troubleshoot the code (see what error logs are generated) if the desire is as described, disable the top category, and answer that you want all of the sub-information disabled as well... That will provide the same result as the code was written. Also, did you clear the cache of the browser between running it (yes a white screen was expected) and checking the store front...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  9. #9
    Join Date
    Jul 2011
    Posts
    107
    Plugin Contributions
    0

    Default Re: Is there a way to mark an entire category at out of stock?

    Okay, so I dug around to see if I could see if anything was happening and it appears that the code has only disabled some of the products....and the weird thing is that I cannot for the life of me find a pattern on why some were disabled and some weren't. For example, in the main category in the quantity column is now shows 176 of 322 active. So, it 'deactivated' 176 listings. Unfortunately, this really wasn't what I was going for. I'd still like the products to show on my site but I would like them to show as 'sold out' or the add to cart button removed such as when the store is set to showcase.

    Something I failed to ask in my previous message is once I have 'activated' the disable_category code, how do I DE-activate it so the products become enabled again?

    Thanks :)

  10. #10
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: Is there a way to mark an entire category at out of stock?

    Quote Originally Posted by jcrewe View Post
    Okay, so I dug around to see if I could see if anything was happening and it appears that the code has only disabled some of the products....and the weird thing is that I cannot for the life of me find a pattern on why some were disabled and some weren't. For example, in the main category in the quantity column is now shows 176 of 322 active. So, it 'deactivated' 176 listings. Unfortunately, this really wasn't what I was going for. I'd still like the products to show on my site but I would like them to show as 'sold out' or the add to cart button removed such as when the store is set to showcase.

    Something I failed to ask in my previous message is once I have 'activated' the disable_category code, how do I DE-activate it so the products become enabled again?

    Thanks :)
    So the code file that was generated above only activates when called upon... That happens by knowing the admin directory and the filename. To prevent any including yourself from deactivating product, remove the file from the server.

    As to undoing the sql that was run, could assign a status of 1 for all product that has zero quantity, but this will include product that was previously disabled because of having zero quantity remaining...

    Maybe I overlooked it, but I did try to find something that could be set to disable the add-to-cart and/or prevent product from being added to the cart..but, perhaps in a slightly more hurried fashion than desired (story of today) it was staring me in the face... I was thinking that the possibly could set the quantity add box such that one could not add the product, I suggested possibly making the product call for price as one of the several options presentedn. But even now not entirely sure I understand how the product was set before using the link manager and how it changed after using it... I tried to offer coded examples of how different results could be obtained with the expectation that the existing setup was understood... Bad on me to not ask more questions... Like said, been hurried a little today and as a result not getting/giving the best results...

    Maybe some of the questions got answered, maybe someone else should offer assistance on this one/today...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. Mark product out of stock
    By ZL Conquistador in forum Managing Customers and Orders
    Replies: 17
    Last Post: 19 Jun 2011, 11:07 PM
  2. Out of stock for just one product not entire category
    By MissFrog in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 6 Dec 2010, 07:26 PM
  3. Is there a way to set an attribute for an entire category?
    By tradrockrat in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 21 May 2010, 06:28 PM
  4. ? is there a way to mark all from pending to delivered/shipped
    By roachkazy in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 10 Aug 2009, 05:51 PM
  5. is there a quick way to make several items go out of stock ?
    By teebo in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 9 Aug 2007, 05:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg