Results 1 to 9 of 9
  1. #1
    Join Date
    Jun 2006
    Posts
    298
    Plugin Contributions
    0

    Default Display text on products in certain category only

    I have a category for clearance items (master_categories_id 284). I'd like to display the text "discontinued" on the product info page where the item is in the clearance category. Can anyone help me accomplish this?

  2. #2
    Join Date
    Jun 2006
    Posts
    298
    Plugin Contributions
    0

    Default Re: Display text on products in certain category only


  3. #3
    Join Date
    Apr 2007
    Location
    Ontario, Canada
    Posts
    1,731
    Plugin Contributions
    27

    Default Re: Display text on products in certain category only

    Twitch Add Title to Product Based on Category Name

    add this to includes/templates/YOUR_TEMPLATE/templates/tpl_product_info_display.php

    PHP Code:
    <?php  
    // bof Twitch Add Title to Product Based on Category Name
    $find_the_category_name zen_get_categories_name(zen_get_products_category_id((int)$_GET['products_id']), $_SESSION['languages_id']);

    // Note: Your category name must exactly match the name used in the next line between the quotes.
    if ($find_the_category_name == 'Discontinued') {

    //echo $find_the_category_name;
    echo '<span class="alert"><strong> This Product has been discontinued </strong></span>';

    } else {

    //do nothing or add your text here

    }
    // eof Twitch Add Title to Product Based on Category Name
    ?>
    This should work nicely :)
    Last edited by twitchtoo; 3 Mar 2015 at 07:51 PM.
    Twitch.
    https://www.twitchtoo.com Do you work for free? Please donate.
    Twitch Base8 - Obsidian - This, is what's new.

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

    Default Re: Display text on products in certain category only

    Much simpler and far easier to maintain is to use the stylesheets to your advantage:

    http://www.zen-cart.com/wiki/index.p...Per-Page-Rules

    For an explanation of why (describing pages in general) see: http://www.zen-cart.com/wiki/index.p...dividual_Pages

    Could delete the above as after rereading the desired action (adding text) it may not be as easy, but might still be possible.
    Last edited by mc12345678; 3 Mar 2015 at 10:10 PM.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    Jun 2006
    Posts
    298
    Plugin Contributions
    0

    Default Re: Display text on products in certain category only

    I did it like this:

    Code:
    <?php if ($cPath == 284) { echo '<div class="productIcon disc">'.TITLE_TXT_CLEARANCE.'</div>'; }?>

  6. #6
    Join Date
    Apr 2007
    Location
    Ontario, Canada
    Posts
    1,731
    Plugin Contributions
    27

    Default Re: Display text on products in certain category only

    Quote Originally Posted by abcisme View Post
    I did it like this:

    Code:
    <?php if ($cPath == 284) { echo '<div class="productIcon disc">'.TITLE_TXT_CLEARANCE.'</div>'; }?>
    Great to see it's working for you!
    Twitch.
    https://www.twitchtoo.com Do you work for free? Please donate.
    Twitch Base8 - Obsidian - This, is what's new.

  7. #7
    Join Date
    Jun 2006
    Posts
    298
    Plugin Contributions
    0

    Default Re: Display text on products in certain category only

    Hm, so that only works if I click on the product from the clearance category.. but a product in clearance may be listed in multiple categories. And if I click on it from a linked category, it doesn't display the "clearance" text. I need to specify the master_categories_id...

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

    Default Re: Display text on products in certain category only

    You can get the current categories_id with:
    $current_category_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: v1.5.5]
    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!

  9. #9
    Join Date
    Jun 2006
    Posts
    298
    Plugin Contributions
    0

    Default Re: Display text on products in certain category only

    This works:

    Code:
    <?php $clearlink = zen_product_in_category($_GET['products_id'], 284);
    if ($clearlink == 1) { echo '<div class="productIcon disc">'.TITLE_TXT_CLEARANCE.'</div>'; }?>

 

 

Similar Threads

  1. v153 Display only certain Category Names
    By dachilla in forum General Questions
    Replies: 2
    Last Post: 24 Jan 2015, 05:50 AM
  2. v150 Display certain text in header only for homepage
    By tips007 in forum General Questions
    Replies: 1
    Last Post: 15 Jan 2013, 10:51 PM
  3. How to display some sitebox only on certain category or product page?
    By ericgu in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 5 Mar 2009, 10:15 AM
  4. Display A Category On Certain Pages Only
    By J. Smith in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 25 Feb 2008, 02:34 AM
  5. only display new products from certain categories?
    By hawkeye in forum General Questions
    Replies: 1
    Last Post: 15 May 2007, 05:15 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