Results 1 to 2 of 2
  1. #1
    Join Date
    May 2005
    Posts
    532
    Plugin Contributions
    0

    Default out of stock on TEXT field

    Can some one help with a quick query. I have some products that are either made to order or supplied direct from the manufacturer or if they are text fields the customer is putting the words in the field to be printed or made up.

    These products have zero stock on Zencart- so if you show stock or in my case show a tick or cross for in / out of stock then these products have a cross. The solution of stocking 10000 in the stock quantity does not work as Zencart is linked to my accounts/warehouse software and so the stock has to reflect the warehouse.

    I need a flag for a product which will the tell zencart product info page to either say in stock or if not flagged to go off and then do the normal checks for stock and attributed stock if appropriate. Is there a setting already built in for this in the case of text fields?

    Wonder if any of you wonderful people could help with the code to do this.


    Thanks

  2. #2
    Join Date
    May 2005
    Posts
    532
    Plugin Contributions
    0

    Default Re: out of stock on TEXT field - show stock status

    okay here is some code that I have used to over ride the stock status and show an image for product being in or out of stock. My first sort of contribution and go at programming so hopefully I have worked it out and will prove useful.


    I have placed this code in the tpl_product_info_display.php file about line 63 so it sits just below price.


    <!--in stock status tick -->
    <?php if (($flag_show_product_info_quantity == 1)) { ?> <div id="stockstatus">

    <?php if ($stock_check_flag == 'dir') { echo STOCK_STATUS_TEXT; echo TEXT_PRODUCT_IN_STOCK_IMAGE; } else { if (($flag_show_product_info_quantity == 1)) { echo STOCK_STATUS_TEXT; echo(($flag_show_product_info_quantity == 1) ?
    '<a>' . ($products_quantity > 0 ? TEXT_PRODUCT_IN_STOCK_IMAGE :
    TEXT_PRODUCT_NOT_IN_STOCK) . '</a>' : '') . "\n";
    }
    }?> </div><?php }
    ?>
    <!-- end of status block -->



    You need create a field in the products table - 'stock_check_flag' in my case.

    I have then created a variable in the main_template_vars.php file

    $stock_check_flag = $product_info->fields['stock_check_flag'];

    and add the variable to the sql statement at line 46 in the same file:

    $sql = "select p.products_id, pd.products_name,
    pd.products_description, p.products_model,
    p.products_quantity, p.products_image,
    pd.products_url, p.products_price,
    p.products_tax_class_id, p.products_date_added,
    p.products_date_available, p.manufacturers_id, p.products_quantity,
    p.products_weight, p.products_priced_by_attribute, p.product_is_free,
    p.products_qty_box_status,
    p.products_quantity_order_max,
    p.products_discount_type, p.products_discount_type_from, p.products_sort_order, p.products_price_sorter, p.stock_check_flag
    from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
    where p.products_status = '1'
    and p.products_id = '" . (int)$_GET['products_id'] . "'
    and pd.products_id = p.products_id
    and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";


    I have used a text field in the products table so I could have different text for different product types. i.e. product I send direct from the manufacturer use dir as in the code above. or if it is a bill of materials and made up of 3 other product I could put bil for example. This is really for our own ref to understand the type of product and why it is flag. you could use a simple true / false flag.


    If any one sees a flaw in my code please let me know. But it seems to work.


    My only other issue is to get this to work with dynamic drop downs but that is a bigger issue. Hope the above is useful for some one or tweaking as appropriate.

    Best wishes

 

 

Similar Threads

  1. Text field - i can't figure it out..
    By RenStar in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 22 Oct 2009, 08:34 AM
  2. sold out text in dropdown menu -attribute stock module
    By pshop in forum All Other Contributions/Addons
    Replies: 3
    Last Post: 18 Oct 2009, 05:03 AM
  3. Getting rid of out of stock text
    By gothicat in forum Templates, Stylesheets, Page Layout
    Replies: 6
    Last Post: 1 Jun 2009, 06:50 PM
  4. Add 'out-of-stock' text to product description list
    By leeudon in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 27 Jun 2007, 03:53 AM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR