Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Adding Date Available to Product Listing

Adding Date Available to Product Listing

Views: 2,180

Results 1 to 7 of 7
14 Feb 2012, 12:05 AM
#1
daniroe avatar

daniroe

New Zenner

Join Date:
Jan 2012
Posts:
6
Plugin Contributions:
0

Adding Date Available to Product Listing

Is there a method for adding the "This product will be in stock..." date to the Product Listing page outputs?
I searched everywhere and nothing...

14 Feb 2012, 12:21 AM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Adding Date Available to Product Listing

You could customize the products listing code with your templates and overrides of:
/includes/modules/product_listing.php

using the code in RED:

        $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 />' : '') : '');
// bof: add date available        
        $products_date_available = zen_products_lookup($listing->fields['products_id'], 'products_date_available');
        if ($products_date_available > date('Y-m-d H:i:s')) {
          $lc_text .= '<br />' . 'Available:' . zen_date_short($products_date_available);
        }
// eof: add date available        
        break;
        case 'PRODUCT_LIST_QUANTITY':

This example puts the date after the price ...

14 Feb 2012, 7:51 PM
#3
daniroe avatar

daniroe

New Zenner

Join Date:
Jan 2012
Posts:
6
Plugin Contributions:
0

Re: Adding Date Available to Product Listing

Ajeh:

You could customize the products listing code with your templates and overrides of:
/includes/modules/product_listing.php

using the code in RED:

    $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 />' : '') : '');

// bof: add date available
$products_date_available = zen_products_lookup($listing->fields['products_id'], 'products_date_available');
if ($products_date_available > date('Y-m-d H:i:s')) {
$lc_text .= '<br />' . 'Available:' . zen_date_short($products_date_available);
}
// eof: add date available
break;
case 'PRODUCT_LIST_QUANTITY':

> 
> This example puts the date after the price ...

Thank you very much, it worked!

Greeting from argentina
12 Mar 2012, 11:19 PM
#4
chadderuski avatar

chadderuski

Totally Zenned

Join Date:
Apr 2006
Location:
Dark Side of the Moon
Posts:
986
Plugin Contributions:
0

Re: Adding Date Available to Product Listing

Ajeh:

You could customize the products listing code with your templates and overrides of:
/includes/modules/product_listing.php

using the code in RED:

    $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 />' : '') : '');

// bof: add date available
$products_date_available = zen_products_lookup($listing->fields['products_id'], 'products_date_available');
if ($products_date_available > date('Y-m-d H:i:s')) {
$lc_text .= '<br />' . 'Available:' . zen_date_short($products_date_available);
}
// eof: add date available
break;
case 'PRODUCT_LIST_QUANTITY':

> 
> This example puts the date after the price ...

Hiya Ajeh!

I know some time ago you said you were working code to make the "Date Available" more usable. Namely, that if the product isn't yet available, you can show it, but not add to cart for checkout.
Did this make it into 1.5? 

If not, would it require much modding to add? 

Thanks!
Chaddro
12 Mar 2012, 11:44 PM
#5
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Adding Date Available to Product Listing

The same code would work in v1.5 but it is not a standard setting as some want people to pre-order and some do not ...

So if you want it, you need to add the custom code yourself to your site ...

20 Oct 2018, 10:39 PM
#6
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Adding Date Available to Product Listing

Twitch Add Date Available to Product Listing for 155f

I've swirled together a simple build on the code mentioned in this thread that works with Zen Cart 1.55f using the long date format.

Tuck it in right under the add to cart/sold out buttons in the product listing here...

includes/modules/YOUR_TEMPLATE/product_listing.php
replace this:
$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;

with this:
$lc_text .= '' . (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 . '' : '') : '');

// bof Twitch Add Product Date Available on Product Listing
// quick lookup for the products_date_available for each product in the list
$find_products_date_available = zen_products_lookup($listing->fields['products_id'], 'products_date_available');

if ($find_products_date_available > date('Y-m-d H:i:s')) {
$lc_text .= '<div class="pL_productDateAvailable">' . 'Available on ' . zen_date_long($find_products_date_available) . '</div>';
}
// eof Twitch Add Product Date Available on Product Listing

    break;

Some nice green text using margins for space...

includes/templates/YOUR_TEMPLATE/css/stylesheet.css
add to the bottom of your stylesheet
:
.pL_productDateAvailable {
margin: .5em auto;
font-size: 1.2em;
color: #3AB54A;
font-weight: bold;
}

The CSS class mimics the name of the one used in the tpl_product_info_display.php for the same use - displaying date added on the product info page.

Display Options:

  • No date found -> Display nothing
  • Date found -> Display long date
  • Date Passed -> Display nothing

In the future this could be tied to the switch being used on the product landing page already -*** $flag_show_product_info_date_available


28 Jul 2022, 5:37 PM
#7
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Adding Date Available to Product Listing

Update for those looking to add Date Added to New Products Listing:

includes/templates/YOUR_TEMPLATE/templates/tpl_modules_products_new_listing.php - Zen 1.57c...

change this:

<?php if (PRODUCT_NEW_LIST_DESCRIPTION > '0') { ?>
      <div class="clearBoth listings-description">
          <?php
            echo $display_products_description;
          ?>
      </div>
</div> <?php $products_new->MoveNext(); **to this:** <?php if (PRODUCT_NEW_LIST_DESCRIPTION > '0') { ?>
      <div class="clearBoth listings-description">
          <?php
            echo $display_products_description;
          ?>
      </div>
<?php } ?> <?php // if ( add switch controls here if needed) { // Twitch Add Date Added to New Products Listing ?> <div id="productDateAdded" class="productGeneral centeredContent"><?php echo TEXT_DATE_ADDED .' '. zen_date_long($products_new->fields['products_date_added']); ?></div> <?php // } ?> </div> <?php $products_new->MoveNext();