Page 1 of 3 123 LastLast
Results 1 to 10 of 21
  1. #1
    Join Date
    Apr 2009
    Location
    Manchester, England
    Posts
    6
    Plugin Contributions
    0

    Default Set products to either "In Stock" or "Out of Stock" on the product listing page.

    Hi, I'm running Zen Cart version 1.3.8a.

    I'd like to display an image below each product to say whether it is in stock, or out of stock, instead of displaying the units in stock.

    I've seen loads of posts about how to do this on the individual product page, but I'd like to do this on the main product listing page (the main shop page).

    I assume something needs adding/altering in:
    tpl_modules_product_listing.php ?

    Thanks in advance!

  2. #2
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Set products to either "In Stock" or "Out of Stock" on the product listing page.

    One simple way to do it:
    1. Admin->Configuration->Product Listing->Products Quantity -- set a column number greater than 0
    2. Alter /includes/modules/product_listing.php, and change:
    Code:
            $lc_text = $listing->fields['products_quantity'];
    to:
    Code:
            $lc_text = ($listing->fields['products_quantity'] > 0 ? zen_image(DIR_WS_IMAGES . 'instock.jpg', 'In Stock', '60', '80', 'class="listingInStockImage"') : zen_image(DIR_WS_IMAGES . 'outofstock.jpg', 'Out Of Stock', '60', '80', 'class="listingOutOfStockImage"'));
    Replace '60' with the appropriate width, and '80' with appropriate height, and create 2 new image files: /images/instock.jpg and /images/outofstock.jpg
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Apr 2009
    Location
    Manchester, England
    Posts
    6
    Plugin Contributions
    0

    Default Re: Set products to either "In Stock" or "Out of Stock" on the product listing page.

    Quote Originally Posted by DrByte View Post
    One simple way to do it:
    1. Admin->Configuration->Product Listing->Products Quantity -- set a column number greater than 0
    2. Alter /includes/modules/product_listing.php, and change:
    Code:
            $lc_text = $listing->fields['products_quantity'];
    to:
    Code:
            $lc_text = ($listing->fields['products_quantity'] > 0 ? zen_image(DIR_WS_IMAGES . 'instock.jpg', 'In Stock', '60', '80', 'class="listingInStockImage"') : zen_image(DIR_WS_IMAGES . 'outofstock.jpg', 'Out Of Stock', '60', '80', 'class="listingOutOfStockImage"'));
    Replace '60' with the appropriate width, and '80' with appropriate height, and create 2 new image files: /images/instock.jpg and /images/outofstock.jpg
    Wow, thanks DrByte! That worked like magic. You're a great contributor to this forum, you always give the best answers. Thanks ^-^

  4. #4
    Join Date
    Jun 2005
    Location
    Cumbria, UK
    Posts
    10,263
    Plugin Contributions
    3

    Default Re: Set products to either "In Stock" or "Out of Stock" on the product listing page.

    Quote Originally Posted by cuppycakez View Post
    ... you always give the best answers...
    ... one would hope so, considering that DrByte wrote most of the zencart software in the first place!
    20 years a Zencart User

  5. #5
    Join Date
    Oct 2007
    Posts
    328
    Plugin Contributions
    0

    Default Re: Set products to either "In Stock" or "Out of Stock" on the product listing page.

    Quote Originally Posted by DrByte View Post
    One simple way to do it:
    1. Admin->Configuration->Product Listing->Products Quantity -- set a column number greater than 0
    2. Alter /includes/modules/product_listing.php, and change:
    Code:
            $lc_text = $listing->fields['products_quantity'];
    to:
    Code:
            $lc_text = ($listing->fields['products_quantity'] > 0 ? zen_image(DIR_WS_IMAGES . 'instock.jpg', 'In Stock', '60', '80', 'class="listingInStockImage"') : zen_image(DIR_WS_IMAGES . 'outofstock.jpg', 'Out Of Stock', '60', '80', 'class="listingOutOfStockImage"'));
    Replace '60' with the appropriate width, and '80' with appropriate height, and create 2 new image files: /images/instock.jpg and /images/outofstock.jpg
    Thanks a lot, I got it working too, however I have been trying for two days now to place the 'In Stock/Out of stock' text underneath the 'Buy it Now' button in the 'Price' column, instead of the 'Qty' column. How can this be done? Any help is much appreciated...thanks

  6. #6
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Set products to either "In Stock" or "Out of Stock" on the product listing page.

    To put it under the buy-now button instead of in the Qty column:
    Instead of replacing the line I originally mentioned, add it as a new line (with a slight adjustment) as shown here:
    Code:
            $lc_text .= '<br />' . zen_get_buy_now_button($listing->fields['products_id'], $the_button, $products_link) . '<br />' . zen_get_products_quantity_min_units_display($listing->fields['products_id']);
            $lc_text .= '<br />' . ($listing->fields['products_quantity'] > 0 ? zen_image(DIR_WS_IMAGES . 'instock.jpg', 'In Stock', '60', '80', 'class="listingInStockImage"') : zen_image(DIR_WS_IMAGES . 'outofstock.jpg', 'Out Of Stock', '60', '80', 'class="listingOutOfStockImage"'));
            $lc_text .= '<br />' . (zen_get_show_product_switch($listing->fields['products_id'], 'ALWAYS_FREE_SHIPPING_IMAGE_SWITCH') ? (zen_get_product_is_always_free_shipping($listing->fields['products_id']) ? TEXT_PRODUCT_FREE_SHIPPING_ICON . '<br />' : '') : '');
            break;
            case 'PRODUCT_LIST_QUANTITY':
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  7. #7
    Join Date
    Oct 2007
    Posts
    328
    Plugin Contributions
    0

    Default Re: Set products to either "In Stock" or "Out of Stock" on the product listing page.

    Great thanks a lot, exactly what I needed!

  8. #8
    Join Date
    Jun 2009
    Location
    Kent, UK
    Posts
    347
    Plugin Contributions
    5

    Default Re: Set products to either "In Stock" or "Out of Stock" on the product listing page.

    is it possible to use this method (or a modified version) to replace the quantity in stock text for product info display?

    so to replace the line :

    HTML Code:
     <?php echo (($flag_show_product_info_quantity == 1) ? '<li>'. TEXT_PRODUCT_QUANTITY. '</li>'  : '') . "\n"; ?>
    with something which simply shows and in stock or out of stock image?

  9. #9
    Join Date
    Jun 2009
    Location
    Kent, UK
    Posts
    347
    Plugin Contributions
    5

    Default Re: Set products to either "In Stock" or "Out of Stock" on the product listing page.

    no worries, i added a bit of code to display above my product image and added a new button to my template tpl_product_info_display.php and also updated my button definitions in button_names.php to include the new button.

    the code is below incase anyone else is looking for it.

    HTML Code:
    <!--bof stock image-->
    <div id="stock_image">
    <?php 
    if ($products_quantity > 0){
    		echo zen_image_button(BUTTON_IMAGE_INSTOCK_SMALL, BUTTON_IMAGE_INSTOCK_ALT);
    }
    else
    {	echo zen_image_button(BUTTON_IMAGE_SOLD_OUT_SMALL, BUTTON_IMAGE_SOLD_OUT_ALT);
    } ?> 
    </div>
    <!--eof stock image-->

  10. #10
    Join Date
    Jul 2007
    Posts
    75
    Plugin Contributions
    0

    Default Re: Set products to either "In Stock" or "Out of Stock" on the product listing page.

    How can this be done to simply display the text (not images) 'In stock' on the product display page and also on product listing pages (and other pages where the quantity is displayed)?

    Many thanks.

 

 
Page 1 of 3 123 LastLast

Similar Threads

  1. v152 Segregating "In Stock" and "Out of Stock" items
    By Peter M Dodge in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 3 Dec 2013, 12:42 PM
  2. "sale pending" instead of "out of stock"
    By taopro in forum General Questions
    Replies: 1
    Last Post: 25 Sep 2010, 11:04 AM
  3. Display "Out of Stock" by the product on index pages
    By sc0rpiongirl in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 4 Sep 2007, 05:13 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