Zen Cart Logo
Forums / General Questions / Products Available Date

Products Available Date

Views: 1,962

Results 1 to 17 of 17
10 Jun 2015, 1:22 PM
#1
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Products Available Date

Hi

We have been using the products available date to display forthcoming books soon to be released.

Problem is we are sure that one was set with a due date of 9th June and this morning it has gone from the list. Does the system automatically remove these dates once they are passed? I wouldn't have thought so but now I'm not so sure.

I've even looked in PHP Admin and sorted on product_expected and only the 8 that show on the site are there with a date.

10 Jun 2015, 1:27 PM
#2
ajeh avatar

ajeh

Oba-san

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

Re: Products Available Date

Yes, once the Available Date has happened then the date is removed from the Product record ...

10 Jun 2015, 1:36 PM
#3
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Products Available Date

Ajeh:

Yes, once the Available Date has happened then the date is removed from the Product record ...

Oh how annoying!!! We're using it as a Product Expected date rather than a Product Available date ..... going to have to rethink this then

10 Jun 2015, 2:07 PM
#4
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Products Available Date

Would anybody happen to know where the code for this automatic date removal sits please? We would like to keep product available even past the date specified if we cannot locate it.

Thanks

10 Jun 2015, 2:44 PM
#5
ajeh avatar

ajeh

Oba-san

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

Re: Products Available Date

Check first that the fieldname is:
products_date_available

vs what you have posted:
product_expected

10 Jun 2015, 2:54 PM
#6
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Products Available Date

Ajeh:

Check first that the fieldname is:
products_date_available

vs what you have posted:
product_expected

Hi AJeh

Yes thanks - I did that work bit out ... just trying to find where it erases the products_data_available field in the database

10 Jun 2015, 3:17 PM
#7
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Products Available Date

Think I may have it:

In Admin/products_expected.php

I have commented out the following:

// $db->Execute("update " . TABLE_PRODUCTS . "
// set products_date_available = NULL
// where to_days(now()) > to_days(products_date_available)");

Should see tomorrow if that does the trick as I have set up a dummy product available tomorrow

10 Jun 2015, 3:41 PM
#8
ajeh avatar

ajeh

Oba-san

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

Re: Products Available Date

You have two files to customize if you NEVER want the products_date_available to change except when you manually change it ...
/your_secret_admin/includes/modules/update_product.php

comment out the line that removes it when in the Admin:

  } elseif ($_POST['products_model'] . $_POST['products_url'] . $_POST['products_name'] . $_POST['products_description'] != '') {
    $products_date_available = zen_db_prepare_input($_POST['products_date_available']);
[B]//[/B]    $products_date_available = (date('Y-m-d') < $products_date_available) ? $products_date_available : 'null';
    // Data-cleaning to prevent MySQL5 data-type mismatch errors:

then in the Catalog, you need to change the date filter so ALL dates are valid unless blank by commenting the old method and adding a new date range that will force it to always be valid when not blank ...
/includes/functions/functions_lookups.php

// build date range for upcoming products
  function zen_get_upcoming_date_range() {
    // 120 days; 24 hours; 60 mins; 60secs
    $date_range = time();
    $zc_new_date = date('Ymd', $date_range);
// need to check speed on this for larger sites
//    $new_range = ' and date_format(p.products_date_available, \'%Y%m%d\') >' . $zc_new_date;
[B]//[/B]    $new_range = ' and p.products_date_available >' . $zc_new_date . '235959';
[B]$new_range = ' and p.products_date_available > "2000-01-01"';
[/B]    return $new_range;
  }
10 Jun 2015, 3:57 PM
#9
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Products Available Date

Ajeh:

You have two files to customize if you NEVER want the products_date_available to change except when you manually change it ...
/your_secret_admin/includes/modules/update_product.php

comment out the line that removes it when in the Admin:

} elseif ($_POST['products_model'] . $_POST['products_url'] . $_POST['products_name'] . $_POST['products_description'] != '') {
$products_date_available = zen_db_prepare_input($_POST['products_date_available']);
[B]//[/B] $products_date_available = (date('Y-m-d') < $products_date_available) ? $products_date_available : 'null';
// Data-cleaning to prevent MySQL5 data-type mismatch errors:

> 
> then in the Catalog, you need to change the date filter so ALL dates are valid unless blank by commenting the old method and adding a new date range that will force it to always be valid when not blank ...
> /includes/functions/functions_lookups.php
> ```
// build date range for upcoming products
  function zen_get_upcoming_date_range() {
    // 120 days; 24 hours; 60 mins; 60secs
    $date_range = time();
    $zc_new_date = date('Ymd', $date_range);
// need to check speed on this for larger sites
//    $new_range = ' and date_format(p.products_date_available, \'%Y%m%d\') >' . $zc_new_date;
[B]//[/B]    $new_range = ' and p.products_date_available >' . $zc_new_date . '235959';
[B]$new_range = ' and p.products_date_available > "2000-01-01"';
[/B]    return $new_range;
  }

You'r a star thank you .. I will get these changed :)

10 Jun 2015, 4:01 PM
#10
ajeh avatar

ajeh

Oba-san

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

Re: Products Available Date

You are most welcome ... :smile:

Remember, you will have to remove the date manually when you want it to go away ...

10 Jun 2015, 6:17 PM
#11
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Products Available Date

Ajeh:

You are most welcome ... :smile:

Remember, you will have to remove the date manually when you want it to go away ...

Hi Ajeh

That first change in Admin is still causing a reset to a null value

10 Jun 2015, 6:24 PM
#12
ajeh avatar

ajeh

Oba-san

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

Re: Products Available Date

What product_types do you use?

There is a separate file for each Product Type ...

10 Jun 2015, 6:30 PM
#13
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Products Available Date

I've had to revert back to the original in Admin

In Admin/products_expected.php

I have commented out the following:

// $db->Execute("update " . TABLE_PRODUCTS . "
// set products_date_available = NULL
// where to_days(now()) > to_days(products_date_available)");

10 Jun 2015, 6:31 PM
#14
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Products Available Date

Ajeh:

What product_types do you use?

There is a separate file for each Product Type ...

Product - General

10 Jun 2015, 6:58 PM
#15
ajeh avatar

ajeh

Oba-san

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

Re: Products Available Date

I believe you will need both ... the code that I gave you and the code that you commented out in /your_secret_admin/products_expected.php ...

And to see it in the Preview, add the code in RED:
/your_secret_admin/includes/modules/product/preview_info.php

<?php
      if ([B]true || [/B]$pInfo->products_date_available > date('Y-m-d')) {
?>
      <tr>
        <td align="center" class="smallText"><?php echo sprintf(TEXT_PRODUCT_DATE_AVAILABLE, zen_date_long($pInfo->products_date_available)); ?></td>
      </tr>
<?php
      } else {
?>
      <tr>
        <td align="center" class="smallText"><?php echo sprintf(TEXT_PRODUCT_DATE_ADDED, zen_date_long($pInfo->products_date_added)); ?></td>
      </tr>
<?php
      }
?>

Silly little extra things to tidy up that I missed ... :lookaroun

10 Jun 2015, 7:05 PM
#16
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Products Available Date

Ajeh:

I believe you will need both ... the code that I gave you and the code that you commented out in /your_secret_admin/products_expected.php ...

And to see it in the Preview, add the code in RED:
/your_secret_admin/includes/modules/product/preview_info.php

<?php if ([B]true || [/B]$pInfo->products_date_available > date('Y-m-d')) { ?>
  <tr>
    <td align="center" class="smallText"><?php echo sprintf(TEXT_PRODUCT_DATE_AVAILABLE, zen_date_long($pInfo->products_date_available)); ?></td>
  </tr>
<?php } else { ?>
  <tr>
    <td align="center" class="smallText"><?php echo sprintf(TEXT_PRODUCT_DATE_ADDED, zen_date_long($pInfo->products_date_added)); ?></td>
  </tr>
<?php } ?>
> 
> Silly little extra things to tidy up that I missed ... :lookaroun

That all seems to be working fine thank you .. could not have done it without your help!!!!!

And not a problem with manually removing the dates - that was the whole intention once we locate and upload the books

:)
10 Jun 2015, 8:22 PM
#17
ajeh avatar

ajeh

Oba-san

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

Re: Products Available Date

You are most welcome and thanks for pointing out that I should have searched further on this one before I posted the code changes so that I would not have missed any of the additional ones needed ... :cool: