Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2010
    Posts
    897
    Plugin Contributions
    0

    Default Customizing tpl_product_info_display.php: If product qty=0, then....

    Hi,

    I'm working on a site that offers Same-Day-Shipping for products in stock. I added a little disclaimer like so:
    <div id="disclaimer1">
    *<em>Order must be received by 2pm EST.</em>
    </div>

    However, when product quantity is zero, I would like the disclaimer not to show. I imagine something like this getting added to the page in the event the item is not in stock:
    <style type="text/css">#disclaimer1{ display: none; }</style>

    Any thoughts on how I could write a routine that checks available quantity? And, if that quantity is zero, inserts the display:none?

    Thanks!

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,699
    Plugin Contributions
    95

    Default Re: Customizing tpl_product_info_display.php: If product qty=0, then....

    What page is the page?

  3. #3
    Join Date
    Apr 2010
    Posts
    897
    Plugin Contributions
    0

    Default Re: Customizing tpl_product_info_display.php: If product qty=0, then....

    tpl_product_info_display.php

    That's the page that displays a product, after a visitor drills down through the category and picks an actual product.

    On that page, to the product detail list I have added:
    <li><strong>Availability: <span style="color: #ff0000;">In Stock!</span> Same-Day-Shipping!*</strong></li>

    Then below the add-to-cart, I added:
    <div id="disclaimer1">
    *<em>Order must be received by 2pm EST.</em>
    </div>

    So really, I will want both divs to disappear: productDetailsList and disclaimer1
    Last edited by Feznizzle; 4 Oct 2017 at 07:21 PM.

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

    Default Re: Customizing tpl_product_info_display.php: If product qty=0, then....

    If "in-stock" is as simple as having a quantity greater than 0 then:
    Code:
    Some amount of html<?php if ($products_quantity > 0) {
    ?>html to be displayed<?php
    } ?>more html
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    Apr 2010
    Posts
    897
    Plugin Contributions
    0

    Default Re: Customizing tpl_product_info_display.php: If product qty=0, then....

    I used your in two places like this:
    FIRST (this one is in product details list)
    <?php if ($products_quantity > 0) {echo (($flag_show_product_info_quantity == 1) ? '<li>' . TEXT_PRODUCT_QUANTITY . '</li>' : '') . "\n"; } ?>

    SECOND (below my add to cart)
    <!--bof disclaimer -->
    <?php if ($products_quantity > 0) {echo
    '<div id="disclaimer1">*<em>Order must be received by 2pm EST.</em></div>'
    ;} ?>
    <!--eof disclaimer -->

    Worked perfect, thanks MC!

    Those are a little different than what you suggested. Had to add "echo", some apostrophes, and semicolon before close.

    Did I do anything wrong?

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

    Default Re: Customizing tpl_product_info_display.php: If product qty=0, then....

    Quote Originally Posted by Feznizzle View Post
    I used your in two places like this:
    FIRST (this one is in product details list)
    <?php if ($products_quantity > 0) {echo (($flag_show_product_info_quantity == 1) ? '<li>' . TEXT_PRODUCT_QUANTITY . '</li>' : '') . "\n"; } ?>

    SECOND (below my add to cart)
    <!--bof disclaimer -->
    <?php if ($products_quantity > 0) {echo
    '<div id="disclaimer1">*<em>Order must be received by 2pm EST.</em></div>'
    ;} ?>
    <!--eof disclaimer -->

    Worked perfect, thanks MC!

    Those are a little different than what you suggested. Had to add "echo", some apostrophes, and semicolon before close.

    Did I do anything wrong?
    Not "wrong". It is in a style that where files are edited, they could possibly be edited to be entered differently. As code editing software (IDEs for example) has gotten better, it can identify unmatched html for example in the midst of php code when the html is presented as html instead of echoed php. The second example would be cleaner than the first in this format:

    Code:
    <?php if ($products_quantity > 0) {
     if ($flag_show_product_info_quantity == 1) { 
    ?><li><?php echo TEXT_PRODUCT_QUANTITY; ?></li><?php
       } 
       echo "\n";
    }
    ?>
    SECOND (below my add to cart)
    Code:
    <!--bof disclaimer -->
    <?php
      if ($products_quantity > 0) {
    ?><div id="disclaimer1">*<em>Order must be received by 2pm EST.</em></div><?php
      } ?>
    <!--eof disclaimer -->
    Then of course there is the hardcoding of the "sentence" instead of using a define and the use of \n instead of say <br /> or something similar to make it easier to apply css if needed or desired. Also your page display for a product without sufficient quantity will be slightly different from one that does wherher quantity is permitted to be displayed or not because of the additional end of line that is used only for when there is sufficient quantity. But nothing is wrong about what was done from a gives the desired results as so far expressed.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #7
    Join Date
    Apr 2010
    Posts
    897
    Plugin Contributions
    0

    Default Re: Customizing tpl_product_info_display.php: If product qty=0, then....

    I substituted my work for your cleaner code, no issues to report.

    Thanks again, MC!

 

 

Similar Threads

  1. v151 Product URL on tpl_product_info_display.php to display only when user is logged in?
    By Matt Staines in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 24 Oct 2013, 09:39 AM
  2. php help with tpl_product_info_display.php
    By JamesM in forum Templates, Stylesheets, Page Layout
    Replies: 7
    Last Post: 29 Sep 2010, 08:09 PM
  3. Align Product Details below Product Description: tpl_product_info_display.php issues
    By gingertea in forum Templates, Stylesheets, Page Layout
    Replies: 6
    Last Post: 16 Aug 2007, 12:36 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